所以我有这种格式的代码:
for-loop1:
for-loop2:
if-statement:
continue
<code here>
<code there>
问题是,如何使continue语句迭代for-loop1而不仅仅是for-loop2?将语句与for-loop2行保持一致将使for循环for it,而不用先执行其余的代码。帮助:(
答案 0 :(得分:1)
如果for-loop2
之后没有代码,则break
将有效地重启外部循环。
for-loop1:
for-loop2:
if-statement:
break
<code here>
<code there>
如果在内循环之后还有其他东西,那么它会做更多的事情。
for-loop1:
restart_loop1 = False
for-loop2:
if-statement:
restart_loop1 = True
break
<code here>
<code there>
if restart_loop1:
continue
<more code here>