Python,期望一个缩进块?一个复杂因素

我正在尝试制作一个基于快速文本的曲棍球队管理游戏,但每当我参考我的一个功能时,我都会得到“预期的缩进块”.不确定我是不是很蠢,也找不到我的错误.

    def startup():
        print "Welcome to the Text Based Hockey League!"
        print "You will be tasked with being a team's General Manager"
        yourTeam = raw_input()
    class tbhl:
        def __init__(self):
            self.teamList["Mustangs", "Wolves", "Indians", "Tigers", "Bears", "Eagles", yourTeam]
    class game:
        def __init__(self, homeScore, awayScore):
            #games left in a team class

startup() #<-The line that the error points to
tbhl = tbhl()
print tbhl.teamList[7]

最佳答案 当您将注释掉的块作为函数的唯一代码时,请使用关键字pass来防止此错误.任何开始新行缩进的代码块都不能留空(或只有注释.)

...
class game:
    def __init__(self, homeScore, awayScore):
        #games left in a team class
        pass

pass是一个no-op,当它在缩进级别寻找某些东西时会让编译器满意.

点赞