Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python,需要缩进块吗?一个并发症_Python_Function - Fatal编程技术网

Python,需要缩进块吗?一个并发症

Python,需要缩进块吗?一个并发症,python,function,Python,Function,我试图制作一个快速的基于文本的曲棍球团队管理游戏,但每当我引用我的一个函数时,我就会得到“预期的缩进块”。不知道我是不是很笨,找不到我的错误或是别的什么 def startup(): print "Welcome to the Text Based Hockey League!" print "You will be tasked with being a team's General Manager" yourTeam = raw_inp

我试图制作一个快速的基于文本的曲棍球团队管理游戏,但每当我引用我的一个函数时,我就会得到“预期的缩进块”。不知道我是不是很笨,找不到我的错误或是别的什么

    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]
def启动():
打印“欢迎来到基于文本的曲棍球联盟!”
打印“您将承担团队总经理的任务”
yourTeam=原始输入()
tbhl类:
定义初始化(自):
团队列表[“野马”、“狼”、“印第安人”、“老虎”、“熊”、“鹰”,你的团队]
班级游戏:
定义初始(自我、主核心、awayScore):
#集体课上剩下的比赛

startup()#当您将注释掉的块作为函数的唯一代码时,还可以使用关键字
pass
来防止此错误。任何开始新行缩进的代码块都不能为空(或仅包含注释)


pass
是一个no-op,当编译器在该缩进级别上查找某个内容时,它会使编译器感到高兴。

但是允许任意缩进的注释。曲棍球程序中发现的问题的解决方案是“pass”!
...
class game:
    def __init__(self, homeScore, awayScore):
        #games left in a team class
        pass