while 循环语句
标志位结束循环:
count=1 flag=True #标志位,结束循环的 while flag: print(count) count=count+1 if count>100: flag=False
break结束循环
count=1 while True: print(count) count=count+1 if count>100: break
注: 遇到break语句时,是会结束整个循环(循环体不再继续执行~)
continue 结束循环
count=1 while count<20: print(count) continue count=count+1
注:循环中遇到continue时,循环体内位于continue后面的语句直接跳过,执行下一次循环(还是会执行循环体,只要满足条件,,但是会跳过continue后面的内容)