当 Python 中出现异常时,我需要停止我的程序。 我该如何实现?
最佳答案
import sys
try:
print("stuff")
except:
sys.exit(1) # exiting with a non zero value is better for returning from an error
关于python - 在 Python 中引发异常时如何停止程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/438894/