海龟图形没有响应 [英] Turtle Graphics Not Responding

查看:43
本文介绍了海龟图形没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用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

这篇关于海龟图形没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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