how to detect program exited in python on windows and do something on exit

前端 未结 2 621
长发绾君心
长发绾君心 2021-01-25 14:35

I want to do something when terminate the python script on windows.

# coding:utf-8
import ctypes
import os

def set_exit_handler():
    def on_exit(event):
              


        
2条回答
  •  Happy的楠姐
    2021-01-25 15:21

    You should use the atexit module, which allows you to register exit hooks without using os specific function calls.

提交回复
热议问题