【发布时间】:2018-01-05 04:22:39
【问题描述】:
我对 Python 并不陌生,这将是一个语法错误。不过,我从来没有真正搞乱过海龟图形,所以这对我来说是全新的。无论如何,我试图制作一个乌龟图形螺旋,它将接受用户的输入(字符串、数字等)并将其变成一个整洁的螺旋。无论如何,我在运行代码时收到此错误消息。
请注意我使用的是 Python 3。
Traceback (most recent call last):
File "spiral_my_name.py", line 6, in <module>
your_name = turtle.textinput("Enter your name", "What is your mame?")
AttributeError: 'module' object has no attribute 'textinput'
这是我从这个语法中得到的错误信息:
import turtle
t = turtle.Pen()
turtle.bgcolor('black')
colors = ['purple', 'pink', 'green', 'blue']
your_name = turtle.textinput("Enter your name", "What is your name?")
for x in range(100):
t.pencolor(colors[x%4])
t.penup()
t.forward(x*4)
t.pendown()
t.write(your_name, font = ("Arial", int ( (x+4) / 4), "bold") )
t.left(92)
现在我个人并不经常为此使用 Python,所以我打算放手,但这是一个属性错误。我有点想知道为什么会这样。
【问题讨论】:
-
是的,除了他使用的是“python 2”我使用的是“Python 3”。
-
这是您的想法还是
print(sys.version)返回大于 3 的版本号? -
确实如此。我的版本是“Python3.4.2”
-
我很感谢您的帮助,但这并没有改变任何事情。我可能在某个地方犯了一个愚蠢的错误。我会继续寻找。再次感谢!上帝保佑!