python achieve abnormal exit

https://blog.csdn.net/u013385362/article/details/81206822

 

Sometimes when a case where a condition is met, it is necessary to terminate the program, you can use sys.exit () to exit the program. sys.exit () raises an exception
1. If the exception is not caught, then the python compiler will exit the back of the program will not be executed.
2. If the exception is caught (try ... except ... finally), catch this exception may do some extra work to clean up the back of the program will continue.
Note: 0 is normal exit, other values (1-127) is not normal, abnormal events can throw for capture.
Another method of terminating the program os._exit ()
using the general sys.exit () can be generally used in os._exit fork out process ()
------------ ---------
author: steadfast heart
source: CSDN
original: https: //blog.csdn.net/u013385362/article/details/81206822
copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/ivyharding/p/11277999.html