for循环
- 在
if...elif...else的多个语句块中只会执行一个语句块
for和while都可以有else语句
for…else
for循环正常执行完的情况下,执行else输出
- 当
for循环中执行了跳出循环的语句(如break),将不执行else代码块的内容
1 2 3 4
| for condition: statement1 else: statement2
|
while循环
while…else
while循环正常执行完的情况下,执行else输出
- 当
while循环中执行了跳出循环的语句(如break),将不执行else代码块的内容
1 2 3 4
| while condition: statement1 else: statement2
|
break语句
break语句用于终止当前循环
- 通常与
if、if...else和if...elif...else语句一起使用
continue语句
continue语句用于跳过当前剩余要执行的代码,执行下一次循环
- 通常与
if、if...else和if...elif...else语句一起使用
pass语句
参考资料
Thank you for your approval.
支付宝
微信支付
WeChat Bezahlung