【发布时间】:2018-10-16 08:56:40
【问题描述】:
我有以下代码可以在turtleworld 中与海龟一起玩:
>>> from swampy.TurtleWorld import *
>>> world = TurtleWorld()
>>> bob = Turtle()
>>> fd(bob, 100)
>>> bob.position()
>>> bob.reset()
执行fd(bob, 100) 行没有问题,但是当我尝试检查海龟位置时,它返回AttributeError:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
bob.position()
AttributeError: 'Turtle' object has no attribute 'position'
为什么会这样?我错过了什么?我已阅读文档,其中指出 position() 和 reset() 方法都应该可用。
【问题讨论】:
-
我不熟悉这个库,但看起来确实没有这样的属性:github.com/AllenDowney/Swampy/blob/master/python3/…
-
谢谢。正如下面 HKJeffer 所说,我将
turtle模块与swampy.TurtleWorld的Turtle类混合在一起。谢谢你的链接,我需要阅读它。
标签: python turtle-graphics swampy