例如,让该程序记下日志文件,然后再手动停止它。
You can use atexit
module: https://docs.python.org/3.5/library/atexit.html
Example:
import atexit
import time
def exit_hook():
print("Exiting!")
atexit.register(exit_hook)
while True:
print("looping...")
time.sleep(1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.