问题
Sorry for dumb question, new to python. I have the following code, running python 3.7:
from turtle import *
color('blue', 'red')
turtle.pu()
turtle.goto(0,0)
turtle.pd()
begin_fill()
forward(55)
left(90)
forward(110)
When I click run, it says I have an error on line three and four, but I can't figure out what's wrong. I tried searching everywhere but I can't find anything that helps me figure out what I did wrong.
回答1:
You need to create an instance of a Turtle object to use it
from turtle import *
bob = Turtle()
color('blue', 'red')
bob.pu()
bob.goto(0,0)
bob.pd()
begin_fill()
forward(55)
left(90)
forward(110)
来源:https://stackoverflow.com/questions/51988690/name-turtle-is-not-defined-on-line-4-in-main-py