Python Turtle代码不工作,显示py lint无成员错误
我相信我已经正确地编码了所有内容,但我不断收到一条错误消息,例如(“模块‘海龟’没有‘重置’成员) 每个“turtle.turtle.”都显示为一个错误。我不太确定我做错了什么。最后我还包括了turtle.done(),这只是我代码的一半 我相信我把一切都编对了 远非如此:循环的终止取决于Python Turtle代码不工作,显示py lint无成员错误,python,turtle-graphics,Python,Turtle Graphics,我相信我已经正确地编码了所有内容,但我不断收到一条错误消息,例如(“模块‘海龟’没有‘重置’成员) 每个“turtle.turtle.”都显示为一个错误。我不太确定我做错了什么。最后我还包括了turtle.done(),这只是我代码的一半 我相信我把一切都编对了 远非如此:循环的终止取决于color的值,该值在循环过程中不会改变;您应该在这里传递一个turtle实例drawU(turtle.turtle)但是正在传递一个turtle类;您的else子句没有意义,实际上是一个no op;您的缩进(
color
的值,该值在循环过程中不会改变;您应该在这里传递一个turtle实例drawU(turtle.turtle)
但是正在传递一个turtle类;您的else
子句没有意义,实际上是一个no op;您的缩进(如图所示)不起作用;您的drawH()
函数丢失
下面是我试图重建您的预期代码,但我不能确定:
from turtle import Screen, Turtle
def drawU(turtle):
turtle.setheading(270)
turtle.forward(150)
turtle.left(90)
turtle.forward(75)
turtle.left(90)
turtle.forward(150)
def drawH(turtle):
pass
color = input('Enter a color: ')
screen = Screen()
turtle = Turtle()
while color != "QUIT":
n = int(input('Enter a number: '))
turtle.reset()
turtle.pencolor(color)
turtle.pensize(10)
if n % 3 == 0 and n % 5 == 0:
turtle.penup()
turtle.setposition(x=0, y=150)
turtle.pendown()
drawU(turtle)
turtle.penup()
turtle.setposition(x=0, y=10)
turtle.pendown()
drawH(turtle)
elif n % 3 == 0:
turtle.penup()
turtle.setposition(x=0, y=150)
turtle.pendown()
drawU(turtle)
elif n % 5 == 0:
turtle.penup()
turtle.setposition(x=0, y=150)
turtle.pendown()
drawH(turtle)
color = input('Enter a color: ')
screen.mainloop()
from turtle import Screen, Turtle
def drawU(turtle):
turtle.setheading(270)
turtle.forward(150)
turtle.left(90)
turtle.forward(75)
turtle.left(90)
turtle.forward(150)
def drawH(turtle):
pass
color = input('Enter a color: ')
screen = Screen()
turtle = Turtle()
while color != "QUIT":
n = int(input('Enter a number: '))
turtle.reset()
turtle.pencolor(color)
turtle.pensize(10)
if n % 3 == 0 and n % 5 == 0:
turtle.penup()
turtle.setposition(x=0, y=150)
turtle.pendown()
drawU(turtle)
turtle.penup()
turtle.setposition(x=0, y=10)
turtle.pendown()
drawH(turtle)
elif n % 3 == 0:
turtle.penup()
turtle.setposition(x=0, y=150)
turtle.pendown()
drawU(turtle)
elif n % 5 == 0:
turtle.penup()
turtle.setposition(x=0, y=150)
turtle.pendown()
drawH(turtle)
color = input('Enter a color: ')
screen.mainloop()