Windows中的KeyboardInterrupt?

时间:2009-09-01 08:22:25

标签: python windows keyboardinterrupt

如何在Windows中生成KeyboardInterrupt?

while True:
    try:
        print 'running'
    except KeyboardInterrupt:
        break

我希望 CTRL + C 停止此程序,但它不起作用。

1 个答案:

答案 0 :(得分:2)

当你遇到Windows控制台时,你的代码工作正常。

Ctrl + C生成KeyboardInterrupt是一项控制台功能。如果你从像SciTE这样的文本编辑器运行它,它将无法工作。