Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么每次运行函数时都会出现错误?_Python - Fatal编程技术网

Python 为什么每次运行函数时都会出现错误?

Python 为什么每次运行函数时都会出现错误?,python,Python,我不确定是什么问题。我进口了乌龟,我吃了两次。下面是我得到的错误: 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_la

我不确定是什么问题。我进口了乌龟,我吃了两次。下面是我得到的错误:

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()
回溯(最近一次呼叫最后一次):
文件“/Users/nn/Documents/sfgh.py”,第189行,在
replaygame()
文件“/Users/nn/Documents/sfgh.py”,第158行,在replaygame中
againornot=replay\u label.textinput(“您想再次播放吗?”,False,align=“right”,font=(“Arial”,20,“normal”))
AttributeError:“Turtle”对象没有属性“textinput”

当您有时间时,请发布您的错误。同时,我认为错误源于此:


尝试编辑此行以在Y周围加引号。againornot=='Y'

(很抱歉格式化不好,我正在使用我的手机。)

这样试试:

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'

你能包含你的错误的图片吗?试着编辑这一行,在Y的周围加上引号。againornot==“Y”:在这个网站上,最好在你的问题文本中包含所有错误的完整错误回溯,这样我们就可以更好地理解如何帮助你,因为不同的错误可能有不同的原因和解决方案
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()