while 条件:
代码块
break:跳出循环语句
continue:跳出本次循环,进入下一次循环。
1 __author__ = ‘qq593‘ 2 #!/usr/bin/env python 3 #-*- coding:utf-8 -*- 4 ‘‘‘ 5 import time 6 a = 0 7 while (a!=100): 8 print("1") 9 time.sleep(1) 10 a+=1 11 print("Over") 12 ‘‘‘ 13 ‘‘‘ 14 import time 15 a = 1 16 while True: 17 print(a) 18 if(a==10): 19 break #用于跳出当前循环语句 continue用于跳出本次循环,继续下一次循环 20 a+=1 21 time.sleep(1) 22 print("End") 23 ‘‘‘ 24 a = 0 25 while a<9: 26 a+=1 27 if(a==7): 28 continue 29 print(a)
时间: 2024-10-17 00:01:27