turtle.done() 在 Spyder 中不起作用 [英] turtle.done() not working in Spyder
问题描述
这个简单的 Python 脚本:
This simple Python script:
import turtle
bob = turtle.Turtle()
bob.forward(50)
turtle.done()
使用 Spyder 运行时会产生错误.第一次运行按预期工作,但在那之后,IPython 控制台引发了一个终结者".使用 turtle.exitonclick()
而不是 turtle.done()
时也会发生同样的情况.我做错了什么?
yields an error when running it using Spyder. The first run works as expected, but after that, the IPython console raises a "Terminator". The same happens when using turtle.exitonclick()
instead of turtle.done()
. What am I doing wrong?
请注意,从 CLI 运行它可以正常工作.
Note that running it from the CLI works fine.
推荐答案
我在 Spyder 中不止一次运行海龟图形程序时遇到问题,我通过转到工具/首选项"解决了这个问题.在运行"部分的控制台"下,选择在新的专用 Python 控制台中执行".
I was having trouble running a turtle graphics program more than once in Spyder, and I solved it by going to "Tools / Preferences". In the "Run" section, under "Console", select "Execute in a new dedicated Python console".
这篇关于turtle.done() 在 Spyder 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!