Python,期望一个缩进块?一个复杂因素
发布时间:2020-12-20 11:35:03 所属栏目:Python 来源:网络整理
导读:我正在尝试制作一个基于快速文本的曲棍球队管理游戏,但每当我参考我的一个功能时,我都会得到“预期的缩进块”.不确定我是不是很蠢,也找不到我的错误. def startup(): print "Welcome to the Text Based Hockey League!" print "You will be tasked with bein
我正在尝试制作一个基于快速文本的曲棍球队管理游戏,但每当我参考我的一个功能时,我都会得到“预期的缩进块”.不确定我是不是很蠢,也找不到我的错误.
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,awayScore): #games left in a team class pass pass是一个no-op,当它在缩进级别寻找某些东西时会让编译器满意. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |