import turtle
def replaygame():
replay_label = turtle.Turtle()
replay_label.speed(0)
replay_label.color("White")
replay_label.penup()
replay_label.setposition(-290,280)
againornot = replay_label.textinput("Do you want to play again Y/N ?",False, align = "right", font = ("Arial" , 20, "normal"))
if againornot == Y:
True
else:
False
replaygame()
我不确定是什么问题。我进口了乌龟,经历了两次。这是我遇到的错误:
Traceback (most recent call last):
File "/Users/nn/Documents/sfgh.py", line 189, in <module>
replaygame()
File "/Users/nn/Documents/sfgh.py", line 158, in replaygame
againornot = replay_label.textinput("Do you want to play again Y/N ?",False, align = "right", font = ("Arial" , 20, "normal"))
AttributeError: 'Turtle' object has no attribute 'textinput'
答案 0 :(得分:1)
请在有时间时发布您的错误。同时,我认为错误源于此:
尝试编辑此行以再次在Y周围加上引号或不==‘Y’
(为格式不正确而致歉,我正在使用手机。)
答案 1 :(得分:0)
像这样尝试:
import turtle
def replaygame():
replay_label = turtle
replay_label.speed(0)
replay_label.color("White")
replay_label.penup()
replay_label.setposition(-290,280)
againornot = replay_label.textinput('Play Again', "Do you want to play again Y/N ?")
if againornot == Y:
True
else:
False
replaygame()