早睡早起,方能养生
Sleep early rise early, way to keep healthy

Python跳出循环 break continue 基础用法

super
2022-12-14 23:59
views 1679

Python跳出循环 break continue 基础用法

 

array = [1, 2, 3, 4, 5, 6]

for i in array:
    if i == 2:
        # 结束本次循环
        continue
    print(i)

print('=====')

for i in array:
    if i == 2:
        # 结束整个循环
        break
    print(i)

 



分享
0 条讨论
top