擅长:python、mysql、java
<p>如果触发了条件,可以使用<a href="https://docs.python.org/3.7/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops" rel="nofollow noreferrer">break statement</a>退出for循环。你知道吗</p>
<p>编辑:在没有数据文件的情况下,很难使用github上的代码来实现这一点,但这里有一个与您的用例类似的玩具示例:</p>
<pre><code>classes= [0,2,2,1,2]
for item in (classes): # here is my classes id is retrieved
if(item == 2):
print("e waste detected")
break
print("post-loop")
</code></pre>
<p>除去中断符,您将看到现在看到的行为—但是请注意缩进,它应该在if语句中。你知道吗</p>