大佬教程收集整理的这篇文章主要介绍了如何在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,handler) <built-in function default_int_handler>
按ctrl-c:
>>> KeyboardInterrupt >>>
我可以验证处理程序是否正在安装Python端作为SIGINT的处理程序(调用signal.signal第二个计时器返回我的处理程序).如何在Windows上捕获SIGINT?
以上是大佬教程为你收集整理的如何在Windows上捕获Python中的SIGINT?全部内容,希望文章能够帮你解决如何在Windows上捕获Python中的SIGINT?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。