更新时间:2023-11-17 11:17:46
我认为这是缩进错误的结果.在您发布的代码中,您有
I think this is the result of an indentation error. In your posted code, you have
class Game(object):
def __init__(self, start):
[...]
print "time. You won!"
exit(0)
a_game = Game("central_corridor")
a_game.play()
这样你就定义了 a_game
inside Game
类,当 Game
尚未定义时.将其向左移动以将其移动到 Game
范围之外,即
So that you're defining a_game
inside the Game
class, when Game
isn't defined yet. Shift it to the left to move it outside the Game
scope, i.e.
a_game = Game("central_corridor")
a_game.play()
(与 class Game(object):
处于同一级别).
(on the same level as class Game(object):
).