Exception Attributes
OSError.strerror — exception attribute
Read the diagnostic message associated with the OS failure. OS-generated strings may vary by platform and language; branch on errno or the exception subclass instead. In a manually constructed OSError the supplied message is retained.
Formal Syntax & Structure
python syntaxpython
error.strerrorReturn Value
str | None
Error message when provided.
Working Example
Example Snippetpython
import errnoerror = OSError(errno.ENOENT, "missing input", "input.txt", None, "output.txt")print(error.strerror)