python 退出程式sys.exit 的退出碼
阿新 • • 發佈:2019-01-25
檢視python手冊,得到下列資訊
sys.exit([arg])
Exit from Python. This is implemented by raising the SystemExit exception, so cleanup actions specified by finally clauses of try statements are honored, and it is possible to intercept the exit attempt at an outer level.
The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. If it is an integer, zero is considered “successful termination” and any nonzero value is considered “abnormal termination” by shells and the like.
Since exit() ultimately “only” raises an exception, it will only exit the process when called from the main thread, and the exception is not intercepted.
總得來說就是,正常和預設退出是 0 其他都是異常退出,為非零。
對於非零更深的分類,不同系統規定不一樣