python os._exit(0) and sys.exit(0)

os._exit(n)

Exit to the system with status n, without calling cleanup handlers, flushing stdio buffers, etc. Availability: Macintosh, Unix, Windows.

Note: The standard way to exit is sys.exit(n)_exit() should normally only be used in the child process after a fork().


sys.exit(n)

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
.

原文地址:https://www.cnblogs.com/zhonghan/p/3209860.html