如何在Windows上捕获Python中的SIGINT?

(类似于这个问题 )

在Python 2.7下的UNIX上,在Python提示符下:

>>> import signal >>> def handler(signal, frame): ... print 'welcome to the handler' ... >>> signal.signal(signal.SIGINT, handler) <built-in function default_int_handler> 

我按ctrl-c

  >>> welcome to the handler >>> 

在Windows上:

  >>> import signal >>> def handler(signal, frame): ... print 'welcome to the handler' ... >>> signal.signal(signal.SIGINT, handler) <built-in function default_int_handler> 

按下ctrl-c后:

  >>> KeyboardInterrupt >>> 

我可以validationhandler正在安装Python端作为SIGINT的处理程序(调用signal.signal第二个计时器返回我的handler )。 我如何在Windows上捕获SIGINT?

Solutions Collecting From Web of "如何在Windows上捕获Python中的SIGINT?"