忽略Python2.7中不带continue语句的索引器

忽略Python2.7中不带continue语句的索引器,python,python-2.7,ignore,continue,try-except,Python,Python 2.7,Ignore,Continue,Try Except,我在for循环中有一个try-and-except语句。我正在查看存储在一个(可能过于复杂)列表中的数据,该列表本身存储在defaultdict中。我希望使用索引器,但当它们出现时,我不需要比较任何数据,所以我希望忽略错误。以下是我当前的代码: for key, list_item in defdict.iteritems(): if len(list_item) == 2: if len(list_item[0][1]) > 1 or len(list_item[

我在for循环中有一个try-and-except语句。我正在查看存储在一个(可能过于复杂)列表中的数据,该列表本身存储在defaultdict中。我希望使用索引器,但当它们出现时,我不需要比较任何数据,所以我希望忽略错误。以下是我当前的代码:

for key, list_item in defdict.iteritems():
    if len(list_item) == 2:
        if len(list_item[0][1]) > 1 or len(list_item[1][1]) > 1:
            compare00,compare01=[],[]
            if another_list.__contains__(list_item[0][0]):
                try:
                    for item in defdict.iteritems():
                        if item[1][0][0] == list_item[0][0]:
                            compare00.append(compare_function(item))
                except IndexError:
                    continue
            if another_list.__contains__(list_item[1][0]):
                try:
                    for item in defdict.iteritems():
                        if item[1][1][0] == list_item[1][0]:
                            compare10.append(compare_function(item))
                except IndexError:
                    continue
        print compare00,compare10
        #etc
此后,我意识到
continue
语句不正确。我的
if
语句不必相互排斥,因此,无论是转到循环的下一次迭代(
继续
)还是离开循环(
中断
)都不合适。除了索引器:之外的空白
,即没有
continue
,是不正确的语法。我应该如何忽略错误? 谢谢
Dave.

使用
pass
语句而不是
continue
语句使用
pass
语句而不是
continue
语句如果要继续循环,请使用not
continue


如果要停止循环,请使用“不
继续”
如果要继续循环,请使用“不
继续”


如果要停止循环,请使用not
continue

或任何有效代码,但不计算更改任何内容
break
将有助于查看问题下的注释:
break
。这是我需要的答案。我以前只使用了
pass
作为占位符。我没想到会在这里,但效果很好。信息:或者即使是任何有效代码但不计算以更改任何内容的内容
break
都将有助于查看问题下的注释RE:
break
。这是我需要的答案。我以前只使用了
pass
作为占位符。我没想到会在这里,但效果很好。信息:如果这不清楚,很抱歉。“我不想继续”是指我想在循环的这个迭代中执行更多的代码,因此既不需要
break
也不需要
continue
。我已经相应地编辑了这个问题。如果不清楚,很抱歉。“我不想继续”是指我想在循环的这个迭代中执行更多的代码,因此既不需要
break
也不需要
continue
。我已经相应地编辑了这个问题。