代码:
import atexit, sys, time @atexit.register def execute1(): print("退出时执行1") @atexit.register def execute2(): print("退出时执行2") #atexit.register(execute1) #atexit.register(execute2) if __name__ == "__main__": time.sleep(5) print("应用程序执行中...") sys.exit(1)
执行效果:
标签:__,python,register,程序,print,atexit,退出,执行 From: https://www.cnblogs.com/xuxiaobo/p/17047290.html