循环语句--while

时间:2023-03-09 13:20:37
循环语句--while

有一种循环叫死循环,一经触发,就运行个天荒地老、海枯石烂

 #coding=utf-8
count=0
while True:
print("你是风儿我是沙,缠缠绵绵到天涯。。。",count)
count+=1

 

其实除了时间,没有什么是永恒的,死loop还是少写为好 

上面的代码循环100次就退出吧

 #coding=utf-8
count=0
while True:
print("你是风儿我是沙,缠缠绵绵到天涯。。。",count)
count+=1
if count==100:
print("去你妈的风和沙。。。")
break
上面的代码循环再改一下,count=50至60的时候不打印
 #coding=utf-8
count=0
while True:
count+=1
if count > 50 and count < 60:
continue
print("你是风儿我是沙,缠缠绵绵到天涯。。。",count)
count+=1
if count==100:
print("去你妈的风和沙。。。")
break