https://www..com/weiman3389/p/6047062.html
1》sys.exit()
>>> import sys
>>> help(sys.exit) Help on built-in function exit in module sys: exit(...)
exit([status])
Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status is an integer, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
执行该语句会直接退出程序,这也是经常使用的方法,也不需要考虑平台等因素的影响,一般是退出Python程序的首选方法。
退出程序引发SystemExit异常,(这是唯一一个不会被认为是错误的异常), 如果没有捕获这个异常将会直接退出程序执行,
当然也可以捕获这个异常进行一些其他操作(比如清理工作)。
sys.exit()函数是通过抛出异常的方式来终止进程的,也就是说如果它抛出来的异常被捕捉到了的话程序就不会退出了,
而是去进行一些清理工作。
SystemExit 并不派生自Exception 所以用Exception捕捉不到该SystemEixt异常,应该使用SystemExit