无法阻止 python 中的名称错误
can't stop nameerror in python
当我输入这个...
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
您从未在 class 的可访问范围内定义 Sprite
。这可能是 neglected/faulty 导入的结果。
您可能正在阅读本书编程的有趣介绍
你错过了本书后面给出的 Sprite class。
可以回头搜索sprite函数。
玩得开心建筑火柴人游戏。
谢谢。
当我输入这个...
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
您从未在 class 的可访问范围内定义 Sprite
。这可能是 neglected/faulty 导入的结果。
您可能正在阅读本书编程的有趣介绍 你错过了本书后面给出的 Sprite class。 可以回头搜索sprite函数。 玩得开心建筑火柴人游戏。 谢谢。