乌龟养乌龟。 Mac 上 PyCharm 和 IDLE 中的终结者错误

问题描述 投票:0回答:1

我正在使用最新版本的Python,但海龟图形仍然无法工作。

from turtle import Turtle, Screen

timmy = Turtle()

my_screen = Screen()

my_screen.exitonclick()

timmy.shape("turtle")

输出:

Traceback (most recent call last) :
File
"/Users/memyselfandabhi/PycharmProjects/day16-start/main.py", line 10, in <module>
timmy.shape ("turtle")
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/turtle.py", line 2779, in shape
self._update()
File "/Library/Frameworks/Python. framework/Versions/3.11/Lib/python3.11/turtle.py", Line 2661, in
_update
self._update_data()
File "/Library/Frameworks/Python. framework/Versions/3.11/lib/python3.11/turtle.py", line 2647, in
_update_data
self.screen._incrementudc()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/turtle.py", line 1293, in _incrementudc
raise Terminator
turtle. Terminator

我该如何解决这个问题?

我尝试重新安装PyCharm,但没有解决问题。

python macos pycharm turtle-graphics
1个回答
0
投票

你的问题是你的

screen.exitonclick
应该位于文件的末尾,所以它应该看起来像这样:

from turtle import Turtle, Screen

timmy = Turtle()

my_screen = Screen()

timmy.shape("turtle")

my_screen.exitonclick()
© www.soinside.com 2019 - 2024. All rights reserved.