python - AttributeError: 'Turtle' 对象在第 14 行没有属性 'shapesize'
问题描述
我正在尝试在 Repl.it 上制作海龟游戏,但我不知道为什么这个错误不断出现。这是我的代码:
import turtle
wn = turtle.Screen()
wn.bgcolor("white")
wn.setup(width=800, height=800)
wn.tracer(0)
# Set up the ground
ground = turtle.Turtle()
ground.color("white")
ground.shape("square")
ground.speed(0)
ground.shapesize(stretch_wid=200, stretch_len=20)
ground.speed(0)
ground.color("black")
ground.penup()
ground.goto(0, -400)
ground.direction = "stop"
解决方案
似乎 repl.it 上的 turtle 库的实现有些受限,并非所有命令都可用。您可以在本地运行它以使用所有命令或删除不兼容的命令。
推荐阅读
- javascript - Discord bot 无法访问 Google Sheets 获取错误请求缺少有效的 API 密钥
- beautifulsoup - newsletter3k,在第一个“by”字之后的可见文本中查找作者姓名
- build - 如何并行执行 Rake 文件任务
- java - 如何为第一个操作正确地从数组列表中检索数据
- java - 布尔值未在数据库中更改
- node.js - 向我的 nodejs restify 项目添加招摇
- javascript - 动态添加/删除多个输入字段后不清除输入(文本)字段值
- javascript - 如何通过 JS(非数组)附加到 JSON 文件
- vim - 如何使 f 和 t 在 vim 中环绕当前行
- python - 无法从scrapy中提取图像链接