Windows 中的键盘中断?

发布于 2024-08-03 10:32:16 字数 186 浏览 1 评论 0原文

如何在 Windows 中生成键盘中断?

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

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

How to generate a KeyboardInterrupt in Windows?

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

I expected CTRL+C to stop this program but it doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

芸娘子的小脾气 2024-08-10 10:32:16

当运行到 Windows 控制台时,您的代码工作正常。

Ctrl+C 生成键盘中断是控制台功能。如果您从 SciTE 等文本编辑器运行它,它将无法工作。

Your code is working ok when ran into a windows console.

Ctrl+C generating a KeyboardInterrupt is a console feature. If you run it from a text editor like SciTE, it will not work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文