All functions in the os module raise OSError for invalid or unreachable file names and paths or other arguments that are of the correct type but are not accepted by the operating system.
os.strerror ()
in Python is used to get the error message corresponding to the error code .
Syntax: os.strerror (code)
Parameter:
code : A integer value that denotes the error codeReturn Type: This method returns a string representing the error message corresponding to the specified error code .
Code # 1: Using the os method .strerror ()
|
Exit :
Error message corresponding to error code 1: Operation not permitted Error Message corresponding to error code 5: Input / output error
Code # 2: printing first 20 errors
|
Exit :
Error code 1: Operation not permitted Error code 2: No such file or directory Error code 3: No such process Error code 4: Interrupted system call Error code 5: Input / output error Error code 6: No such device or address Error code 7: Argument list too long Error code 8: Exec format error Error code 9: Bad file descriptor Error code 10 : No child processes Error code 11: Resource temporarily unavailable Error code 12: Cannot allocate memory Error code 13: Permission denied Error code 14: Bad address Error code 15: Block device required Error code 16: Device or resource busy Error code 17: File exists Error code 18: Invalid cross-device link Error code 19: No such device Error code 20: Not a directory
Code # 3: Check error message for invalid error code
|
Exit: