使用sys.exit()退出当前程序的执行 import sys if x==0: sys.exit() 转载于:https://www.cnblogs.com/imhuanxi/p/11069471.html