[英]How can I set what will be done when my python program terminates with error?
Is there any method to set certain action when my python program ends abruptly? 当我的python程序突然结束时,有什么方法可以设置某些操作? Especially I want to delete a folder and leave a log what was the error using logging module.
特别是我想删除一个文件夹并留下日志,这是使用日志记录模块的错误。
根据您“突然结束”的含义,可能正在寻找atexit
模块https://docs.python.org/2/library/atexit.html 。
您可以使用错误处理,尤其是使用Try,Except语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.