这里有很多问题。 最好先通过一些带有有效代码的教义来开始。 输入它, 并尝试理解语法长什么样, 如何根据打字来修正您看到的错误 。
当您独立编码时, 请慢一点, 一步一步地操作。 每次修改后运行您的代码, 以确保它按照您的期望行事 。 注意错误 。 错误信息通常会告诉您要修正什么和在哪里 。
首先,这里是工作守则:
from turtle import Screen, Turtle
FONT = "Arial", 16, "normal"
screen = Screen()
screen.bgcolor("darkgreen")
t = Turtle()
t.forward(100)
t.left(90)
t.right(0)
t.write("the", FONT)
screen.exitonclick()
备注:
- All imports should be at the top of the file.
- Import
Screen
before using it.
- Avoid importing the
turtle
module because it has a lot of footguns. Better to use only Turtle
and Screen
classes.
- Create a turtle instance with
Turtle()
. I don t think you ll need Pen
.
Screen()
accepts 0 parameters, as the error message indicates.
FONT
is unused. Pass it to write
.
t.write(the)
isn t a thing--the
is being treated as a variable name, not a string. Use "the"
.