我不知道如何让 turtle python 中的背景颜色起作用

I cant figure out how to get background colour in turtle python to work

我已经弄清楚如何输入背景颜色一两天了。 在我学习的过程中,我得到了一本小册子来学习,但是一旦我读到关于设置屏幕尺寸或背景颜色的章节,它就无法工作了。 我被告知使用代码 bgcolor("colour here"),当它不起作用时,我在网上搜索并发现 turtle.bgcolor("colour here") 也不起作用。

我得到的只是一个错误,指出名称未定义。 setup(number 1, number 2) 也出现了同样的错误,但我在网上找不到替代品。有人可以帮我吗?

我的老师说只需为背景填充一个形状,但我觉得如果我自己想出来会更有成就感。谢谢

下面是我的一些代码片段。

您需要将 from turtle import* 更改为 from turtle import *(额外的 space)

因此您的代码将是:

from turtle import *
setup(800, 500)
bgcolor("black")