1
|
<span style
=
"font-size:16px;"
>
continue
:当条件成立,则会跳出进入下一次循环<br>
break
:当条件成立,将会跳出循环<br><br><br>
#!/usr/bin/env python<br># -*- coding:utf-8 -*-<br>for i in range(10):<br> if i < 3:<br> print("loop", i)<br> else:<br> continue<br> print("ok")<br><br> 执行结果:<br> loop 0<br>ok<br>loop 1<br>ok<br>loop 2<br>ok<br><br></span><br>
|
本文转自 baishuchao 51CTO博客,原文链接:http://blog.51cto.com/baishuchao/1933141