我写了一个python脚本,并收到“无效语法”错误。谁能帮我找到错误?谢谢。
我的代码片段:
class Mahjong():
mentsu_map = {}
def __init__(self):
if len(Mahjong.mentsu_map) == 0:
m = Mahjong.mentsu_map
m[0] = [0, 0]
tablefile = open("pretable.data", "r")
try:
for line in tablefile:
ls = map(int, line.split(' '))
m[ls[0]] = [ m[ls[1], m[ls[2]] ]
finally: # invalid syntax here
tablefile.close()
def shanten(self, ht):
pass
我的错误输出是:
finally:
^
SyntaxError: invalid syntax
你忘了 ]
m[ls[0]] = [ m[ls[1]], m[ls[2]] ]
代替
m[ls[0]] = [ m[ls[1], m[ls[2]] ]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句