python for 跳出循环

daizichuan / 2023-07-25 / 原文

(99条消息) Python中跳出循环的两种方法_python跳出循环_在线码BUG的博客-CSDN博客

# 结束本次循环,继续下次循环
for i in range(1,10):
    if i==3:
        continue
    else:
        print('循环了',i,'')

# 结束for循环
for i in range(1,10):
    if i==3:
        break
    else:
        print('循环了',i,'')