如何停止IDLE中的Python程序执行 [英] How to stop Python program execution in IDLE
问题描述
我有一个使用 plt.show()
作为最后一条指令的python脚本。当它运行时,IDLE仅在最后一条指令之后挂起。我得到了图像,但没有得到提示。
I have a python script that uses plt.show()
as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back.
在其他脚本上,我通常使用 ctrl-c
中断程序(有时无法立即使用),但是如何使用 plt.show()
来返回提示? Ctrl-c
不起作用...
On other scripts I typically use ctrl-c
to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()
? Ctrl-c
doesn't work...
还有其他方法可以停止程序吗?
Are there other ways to stop the program?
如果有任何区别,这是Windows上的IDLE。
This is IDLE on Windows, if it makes any difference.
推荐答案
I在Windows上使用IDLE和matplotlib时已经看到了此问题。我不知道确切的原因,但是Ctrl-c通常对我有用。如果那对您不起作用,则可以使用常规解释器,而不是直接将绘图写入文件而不是屏幕中。
I have seen this problem with IDLE and matplotlib when using them on Windows. I don't know the exact cause, but Ctrl-c a couple times has typically worked for me. If that doesn't work for you, you can use the normal interpreter instead of write your plot directly to a file instead of the screen.
这是其中之一(多次),以使IDLE的行为不像普通的Python脚本或解释器会话。因此,我通常避免使用IDLE。
This is one of those (plentiful) times when IDLE doesn't behave like a normal Python script or interpreter session. Because of this, I usually avoid IDLE.
这篇关于如何停止IDLE中的Python程序执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!