Python Idle 在我的代码中标记了一个错误,在以下行中:
如果 pos[1] != 6: tbd.append(pushPos(pos[0],pos[1]+1,0)
突出显示 6 ands 后的冒号表示存在语法错误。
它所处的整体功能是:
def clearPDoms(group,store):
for i in store:
removed.append(i[1])
for i in removed:
pos = getPos(i)
tbd = [pushPos(pos)]
ntbd = 1
if pos[2]==0:
if pos[1] != 0:
tbd.append(pushPos(pos[0],pos[1]-1,0)
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0)
if pos[0] != 0:
tbd.append(pushPos(pos[0]-1,pos[1],1))
tbd.append(pushPos(pos[0]-1,pos[1]+1,1))
if pos[0] != 6:
tbd.append(pushPos(pos[0]+1,pos[1],1))
tbd.append(pushPos(pos[0]+1,pos[1]+1,1))
else:
if pos[0] != 0:
tbd.append(pushPos(pos[0]-1,pos[1],1)
if pos[0] != 5:
tbd.append(pushPos(pos[0]+1,pos[1],1)
if pos[1] != 0:
tbd.append(pushPos(pos[0],pos[1]-1,0))
tbd.append(pushPos(pos[0]+1,pos[1]-1,0))
if pos[1] != 7:
tbd.append(pushPos(pos[0],pos[1]+1,0))
tbd.append(pushPos(pos[0]+1,pos[1]+1,0))
for i in tbd:
for j in range(0,len(group)-1):
if check(i,group[j][1]) == True:
del group[j]
非常感谢您的帮助。
请您参考如下方法:
你的括号不平衡。你错过了结束语:
代替:
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0)
做:
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0))
^
