【发布时间】:2011-01-12 03:51:12
【问题描述】:
如何在 python 中提前退出循环?
for a in b:
if criteria in list1:
print "oh no"
#Force loop i.e. force next iteration without going on
someList.append(a)
另外,在 java 中你可以 break 跳出循环,在 Python 中有没有等价物?
【问题讨论】:
-
不要使用
list作为变量名。它隐藏了内置。