sch01ar

break用于完全结束一个循环,跳出循环体,执行循环后面的语句

# -*- coding:utf-8 -*-
__author__ = "MuT6 Sch01aR"

count = 0
while count <=10:
    print(\'loop\',count)
    if count == 4:
        break #结束整个循环
    count +=1
print(\'End\')

运行结果

continue用于终止本次循环,继续进行下一轮循环

for i in range(0,10):
    if i == 3:
        continue  # 跳出本次循环,继续接下来的循环
    print(\'loop\', i)
print(\'End\')

运行结果

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-10-31
  • 2021-09-08
  • 2021-08-02
  • 2021-08-26
  • 2022-12-23
  • 2021-11-19
  • 2022-01-11
猜你喜欢
  • 2021-12-18
  • 2021-12-02
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-07-05
相关资源
相似解决方案