Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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 PY IDLE标记错误I don';我不明白_Python_If Statement_Syntax Error - Fatal编程技术网

Python PY IDLE标记错误I don';我不明白

Python PY IDLE标记错误I don';我不明白,python,if-statement,syntax-error,Python,If Statement,Syntax Error,Python Idle正在标记我的代码中的一个错误,行: if pos[1]!=6: 待定。追加(pushPos(pos[0],pos[1]+1,0) 突出显示6个AND后的冒号,表示存在语法错误 如果您需要它,它作为一个整体的功能是: def clearPDoms(group,store): for i in store: removed.append(i[1]) for i in removed: pos = getPos(i)

Python Idle正在标记我的代码中的一个错误,行:
if pos[1]!=6:
待定。追加(pushPos(pos[0],pos[1]+1,0)

突出显示6个AND后的冒号,表示存在语法错误

如果您需要它,它作为一个整体的功能是:

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)
做:


缺少最后一个父项
。应该是:
tbd.append(pushPos(pos[0],pos[1]+1,0))
谢谢!这立刻奏效了。我只是感到困惑,因为IDE高亮显示了冒号,所以我在那里查找错误。@HarryMitage因为if行前面的行缺少右括号,if行被视为它前面行中表达式的一部分。当它到达
时,它放弃了将其作为有效表达式进行解析,并抛出了一个错误。
if pos[1] != 6:
    tbd.append(pushPos(pos[0],pos[1]+1,0))
                                         ^