while 循环的语法如下:
while expression:
suite_to_repeat
while 循环的 suite_to_repeat 子句会一直循环执行, 直到 expression 值为布尔假.
1、计数循环
a = 0 while a < 10: print a a += 1
2、break退出循环
while True: a = 0 print a if a = 9: break a += 1
时间: 2024-10-13 19:54:12
while 循环的语法如下:
while expression:
suite_to_repeat
while 循环的 suite_to_repeat 子句会一直循环执行, 直到 expression 值为布尔假.
1、计数循环
a = 0 while a < 10: print a a += 1
2、break退出循环
while True: a = 0 print a if a = 9: break a += 1