【发布时间】:2015-08-07 00:30:59
【问题描述】:
因此,我将在线课程中的这段代码复制粘贴到我的 python 2.7.10 中并运行它。它说宽度没有定义。我试图寻找解决这个问题的问题,但找不到,而且我开始学习编码,所以我不知道如何导入海龟模块而不给我一个错误。
from turtle import * # loads the turtle library...
width(5) # make the turtle pen 5 pixels wide
shape('turtle') # use a turtle shape!
forward(100) # turtle goes forward 100 steps
right(90) # turtle turns right 90 degrees
up() # turtle lifts its pen up off of the paper
forward(100) # turtle goes forward 100 steps
down() # turtle puts its pen down on the paper
color("red") # turtle uses red pen
circle(100) # turtle draws circle of radius 100
color("blue") # turtle changes to blue pen
forward(50) # turtle moves forward 50 steps
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
from turtle import * # loads the turtle library...
File "turtle.py", line 2, in <module>
width(5) # make the turtle pen 5 pixels wide
NameError: name 'width' is not defined
【问题讨论】:
标签: python module width turtle-graphics