Turtle Graphics Not Responding(海龟图形没有响应)
问题描述
我正在用Python中的turtle包创建图表,它在某种程度上是成功的,除了一个问题.一旦海龟生成了我在代码中的图表,它就会导致程序说没有响应",最终我不得不结束任务.我正在使用 Windows 7.
I am creating diagrams with the turtle package in Python, and it is successful to some extent, except for one problem. Once turtle generates the diagram that I have in code, it causes the program to say "Not responding" and eventually I have to end the task. I am using Windows 7.
你们中有人经历过这种情况或知道根本原因吗?我尝试完全重新安装 Python,但这似乎并没有影响问题.
Have any of you experienced this or know the root cause? I tried reinstalling Python completely, but that didn't seem to affect the problem.
这里有一些示例代码会导致它无法响应:
Here is some example code that will make it fail to respond:
import turtle
from turtle import forward, right, left
forward(50)
推荐答案
我遇到了同样的问题(我在 Win 7 上也是,然后在 Win XP 上也遇到了同样的问题),我只是想通了.
I had the same problem (I was on Win 7 as well, and I then got the same problem on Win XP), and I just figured it out.
完成后你必须说 turtle.done()
.
既然我知道了这一点,那就更有意义了,因为 Python 不知道海龟已经完成,它可能正在等待海龟的另一个命令.
Now that I know this, it makes more sense, because since Python doesn't know that the turtle is done, it's probably waiting for another command for the turtle.
这是我假设您正在使用的库的文档(在 Python 2.7 中).我就是这么想的.它说 Python 2.7,但这也适用于 Python 2.5.
http://docs.python.org/library/turtle.html
Here's the documentation (in Python 2.7) of what library I assume you're using. It's how I figured that out. It says Python 2.7 but this also works for Python 2.5.
http://docs.python.org/library/turtle.html
希望对您或其他阅读本文的人有所帮助,
亚历克斯
Hope that helps (for you or anyone else reading this),
Alex
这篇关于海龟图形没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:海龟图形没有响应


基础教程推荐
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 包装空间模型 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01