python ctrl+c


#!/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')


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM