# -*- coding: utf-8 -*-
import atexit
def close():
print('close')
# 注册方式一
atexit.register(close)
# 注册方式二
@atexit.register
def close_file():
print('close_file')
输出顺序
close_file
close
参考
atexit — 退出处理器
最后
以上就是怕孤独手链最近收集整理的关于Python:标准库atexit退出处理器的全部内容,更多相关Python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复