Python 2.73
Why is it on my laptop when I hit CTRL+C, I can exit the interpreter and on my desktop hitting CTRL+C will make the interpreter shoot back at me a KeyboardInterrupt message. How can I get rid of this KeyboardInterrupt and go back to exiting with CTRL+C!
On my desktop it's required to input CTRL+Z and hitting enter to exit.
我在两台计算机上都使用 PowerShell。同样64位,一个是Win7,一个是Win8
You could change the signal handler for CTRL-C to something that exits the interpreter:
import signal
import sys
signal.signal(signal.SIGINT, lambda number, frame: sys.exit())
您可以将该代码放入一个文件中,以便在交互式会话启动时自动运行,然后将环境变量 PYTHONSTARTUP 设置为该文件的名称:
http://docs.python.org/3/using/cmdline.html?highlight=startup#envvar-PYTHONSTARTUP http://docs.python.org/3/using/cmdline.html?highlight=startup#envvar-PYTHONSTARTUP
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)