while循环

while条件:

  循环体

  无限循环

while True:
    print('吃饭')
    print('睡觉')
    print('打豆豆')

 

  终止循环:1、改变条件。使其不成立

count = 1 
while count <=100:
    print(count)
    count = count+1

       2、break直接跳出循环

while True: 
    print('吃饭')
    print('睡觉')
    break
    print('打豆豆')
print('比赛')

 

       3、continue重新开始循环

while True:
    print('吃饭')
    print'睡觉'continue
    print('打豆豆')
count = 1 
while count < 20:
    print(count)
    continue
    count = count + 1

 

posted @ 2020-05-24 17:31  烟斗和沙漏  阅读(182)  评论(0编辑  收藏  举报