Python在程序退出前执行代码

文章目录 问题描述 解决方案 参考文献 问题描述 在程序退出前执行代码html 解决方案 使用内置库 atexit 的装饰器来修饰要执行的代码python 无论程序在哪里崩溃,都会执行注册过的函数web import atexit @atexit.register def f(): print('结束') if __name__ == '__main__': 1 / 0 参
相关文章
相关标签/搜索