错误代码门户
PythonPython错误代码

OSError

OSError

其他表示形式:EnvironmentError · IOError · WindowsError

代码 OSError · Python 报告的问题。

当系统函数返回与系统相关的错误时,包括 I/O 故障,例如“文件未找到”或“磁盘已满”(不适用于非法参数类型或其他偶然错误),则会引发此异常。 构造函数的第二种形式设置相应的属性,如下所述。如果未指定,属性默认为 None。为了向后兼容,如果传递三个参数,则 args 属性仅包含前两个构造函数参数的 2 元组。 构造函数通常实际上返回 OSError 的子类,如下面的操作系统异常中所述。特定的子类取决于最终的 errno 值。此行为仅在直接或通过别名构造 OSError 时发生,并且在子类化时不会继承。

Google Translate · 此内容为自动翻译。技术术语及适用条件请以英文原文为准。

This exception is raised when a system function returns a system-related error, including I/O failures such as “file not found” or “disk full” (not for illegal argument types or other incidental errors). The second form of the constructor sets the corresponding attributes, described below. The attributes default to None if not specified. For backwards compatibility, if three arguments are passed, the args attribute contains only a 2-tuple of the first two constructor arguments. The constructor often actually returns a subclass of OSError, as described in OS exceptions below. The particular subclass depends on the final errno value. This behaviour only occurs when constructing OSError directly or via an alias, and is not inherited when subclassing.

故障排除与诊断链接

请先确认文档中的产品、版本及发生环境与当前情况一致。