#!/usr/bin/env python
import signal
import sys
import os
def signal_handler(signal, frame):
print('You pressed Ctrl+C!')
# signal.signal(signal.SIGINT, signal_handler)
print('Press Ctrl+C')
# os.system('pause')
class SIGINT_handler():
def __init__(self):
self.SIGINT = False

def signal_handler(self, signal, frame):
print('You pressed Ctrl+C!')
self.SIGINT = True


handler = SIGINT_handler()
signal.signal(signal.SIGINT, handler.signal_handler)

os.system('pause')

相关文章:

  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-08-11
  • 2021-09-21
  • 2021-09-20
相关资源
相似解决方案