标签: python
当用户单击运行该程序的终端右上角的“ X”时,我希望确认自己确实要退出该程序。
到目前为止,我发现的最多的是this,但这仅适用于'ctrl-c',而不是单击'X'。 我还发现
def on_exit(sig, fun=None): print("I can't prevent the exit") win32api.SetConsoleCtrlHandler(on_exit, True)
如果可以阻止退出,那将是完美的选择。