subprocess.CalledProcessError
时间: 2024-05-27 17:14:04 浏览: 70
通过实例解析python subprocess模块原理及用法
subprocess.CalledProcessError is an exception that is raised when a process started by the subprocess module returns a non-zero exit status. This exception is raised with the following attributes:
- cmd: the command that was run
- returncode: the exit status of the process
- output: the output generated by the process (if captured)
This exception is useful for handling errors generated by a subprocess in a Python script. For example, if a Python script runs a shell command using the subprocess module and the command exits with a non-zero exit status, the script can catch the subprocess.CalledProcessError exception and handle it appropriately (e.g. by logging an error message, retrying the command, etc.).
阅读全文