如何在 PyCharm 社区中暂停脚本执行? [英] How to pause script execution in PyCharm Community?

查看:92
本文介绍了如何在 PyCharm 社区中暂停脚本执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了这段代码并试图调试它:

从时间导入*对于范围内的 i (100):睡觉(1)打印(一)

我首先在调试模式下运行此脚本,并尝试通过单击暂停按钮来暂停它,但 暂停 按钮根本不起作用,它只是继续打印新数字.>

然后我直接运行这个脚本(不是在调试模式下),暂停确实阻止了pycharm打印新数字,但脚本实际上仍在后台运行,当我恢复脚本时,它打印了很多数字突然之间.

那么我怎样才能正确地暂停脚本执行呢?

我在一个全新的 Windows 7 中安装了 pycharm 和 python,它仍然表现得像这样.

停止和重新运行按钮工作正常,断点也是如此.但暂停按钮永远不起作用.

解决方案

暂停(暂停输出")按钮只是暂时暂停输出到终端——它对脚本执行没有影响.您可能希望使用带断点的调试模式.

您可以通过单击文本编辑器左侧的空间(左装订线",行号出现在其中,如果您启用了它们)来将断点添加到您的程序中.

有关详细信息,请参阅Pycharm 文档.>

I wrote this piece of code and tried to debug it:

from time import *

for i in range (100):
    sleep(1)
    print(i)

I first run this script in debug mode, and try to pause it by clicking the pause button, but the pause button doesn't work at all, it just keep printing new numbers.

Then I directly run this script (not in the debug mode), the pause did stop pycharm from printing new numbers, but the script is actually still running in the background, when I resume the script, it prints a lot of numbers all of a sudden.

So how can I correctly pause the script execution?

I installed pycharm and python in a whole new windows 7, it still behaves like this.

The stop and rerun button works perfectly, breakpoints too. But the pause button never works.

解决方案

The pause ("Pause Output") button only temporarily suspends output to the terminal - it has no effect on the script execution. You may wish to use debug mode with breakpoints instead.

You can add breakpoints into your program by clicking in the space to the left of the text editor (the "Left Gutter", where line numbers appear, if you have them enabled).

See the Pycharm documentation for more information.

这篇关于如何在 PyCharm 社区中暂停脚本执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆