获取场景未定义错误,任何人都可以看到我做错了什么?

时间:2014-03-30 21:54:49

标签: python

我的所有课程都没有定义场景错误。我错过了什么吗?

class Survived(scene):
    quips1 = [
        'Your good at this game',
        'Way to go!',
        'I didnt think you would make it'
        'Thank for playing this game!'
    ]

    def enter(self):
        print Survived.quips [randint(0, len(self.quips1) -1)]
        exit(1)

class Scene(object):
    def enter(self):
        print "This scene is not yet configured. Subclass it and implement enter()."

1 个答案:

答案 0 :(得分:1)

Python区分大小写,您应拼写Survived(Scene)。此外,Scene类应在 Survived之前声明为,否则您将获得未定义的异常。

这样的事情:

class Scene(object):
    def enter(self):
        print "This scene is not yet configured. Subclass it and implement enter()."

class Survived(Scene):
    quips1 = [
        'Your good at this game',
        'Way to go!',
        'I didnt think you would make it'
        'Thank for playing this game!'
    ]

    def enter(self):
        print Survived.quips [randint(0, len(self.quips1) -1)]
        exit(1)