#!/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')
posted on 2018-06-28 16:21  天之城  阅读(2001)  评论(0编辑  收藏  举报