can';不要停止python中的nameerror
当我打这个的时候can';不要停止python中的nameerror,python,nameerror,Python,Nameerror,当我打这个的时候 class doorsprite(Sprite): def __init__(self, game, photo_image, x, y, width, height): Sprite.__init__(self, game) self.photo_image = photo_image self.image = game.canvas.create_image(x, y, \
class doorsprite(Sprite):
def __init__(self, game, photo_image, x, y, width, height):
Sprite.__init__(self, game)
self.photo_image = photo_image
self.image = game.canvas.create_image(x, y, \
image=self.photo_image, anchor='nw')
self.coordinates = Coords(x, y, x + (width / 2), y + height)
self.endgame = True
我得到
Traceback (most recent call last):
File "C:\Users\telta\Desktop\stickman game.py", line 94, in <module>
class DoorSprite(Sprite):
NameError: name 'Sprite' is not defined
回溯(最近一次呼叫最后一次):
文件“C:\Users\telta\Desktop\stickman game.py”,第94行,在
门精灵(精灵)等级:
NameError:未定义名称“精灵”
您从未在类的可访问范围内定义过Sprite
。这可能是由于忽略/错误导入造成的。您从未在类的可访问范围内定义过Sprite
。这可能是由于忽略/错误的导入造成的。您可能正在阅读《编程好玩的介绍》一书中的内容
你错过了本书后面的精灵课程。
您可以返回并搜索sprite函数。
有乐趣的建设stickman游戏。
谢谢。您可能正在阅读一本关于编程的有趣介绍的书 你错过了本书后面的精灵课程。 您可以返回并搜索sprite函数。 有乐趣的建设stickman游戏。
谢谢。您能确保
Sprite
类是在这个类上面定义的吗?它说Sprite
没有定义,您还没有告诉我们您定义它的地方Sprite
来自哪里?它是在其他文件中定义的吗?那你就需要去做。它是在同一个文件中定义的吗?然后,请向我们显示您的完整代码。您的错误和代码不匹配:您是否有类门精灵(精灵):
或类门精灵(精灵):
?(但这只是一个旁注。)你能确保Sprite
类是在这个类上面定义的吗?它说Sprite
没有定义,你还没有告诉我们你在哪里定义的Sprite
来自哪里?它是在其他文件中定义的吗?那你就需要去做。它是在同一个文件中定义的吗?然后,请向我们显示您的完整代码。您的错误和代码不匹配:您是否有类门精灵(精灵):
或类门精灵(精灵):
?(但这只是一个旁白。)你能回答我发布的新问题吗?你能回答我发布的新问题吗?