#archimedes spiral by rays
import math
import turtle
def spiral(t, a, b):
diff=5
number=500
for i in range(number):
t.penup()
t.fd(a+b*i*diff*math.pi/180)
t.pendown()
t.lt(90)
t.fd(10)
t.bk(10)
t.rt(90)
t.penup()
t.bk(a+b*i*diff*math.pi/180)
t.lt(diff)
bob=turtle.Turtle()
bob.speed(1000)
spiral(bob,0, 2)
代码给出如下错误消息:
RESTART: C:\Users\Manish Kumar\Desktop\TBN\repository\Competitive Programming\PYTHON\python scripts\archimedian_spiral.py
Traceback (most recent call last):
File "C:\Users\Manish Kumar\Desktop\TBN\repository\Competitive Programming\PYTHON\python scripts\archimedian_spiral.py", line 4, in <module>
import turtle
File "C:\Users\Manish Kumar\Desktop\TBN\repository\Competitive Programming\PYTHON\python scripts\turtle.py", line 7, in <module>
bob=turtle.Turtle()
AttributeError: module 'turtle' has no attribute 'Turtle'
>>>
我不明白错误信息。我怎样才能使代码工作?这段代码在大约 3 到 4 个月前可以顺利运行。