break:直接跳出循环
while True:
a=input('input a num:')
if a==1:
break
else:
pass
print("in the while")
print('finish!')
输出:
input a num:1
finish!
continue:继续向下执行
judge=True
while judge:
a=input('input a num:')
if a==1:
judge=False
else:
pass
print("in the while")
print('finish!')
输出:
input a num:1
in the while
finish!
judge=True
while judge:
a=input('input a num:')
if a==1:
continue
else:
pass
print("in the while")
print('finish!')
input a num:1 #输入1,继续输入
input a num:2 #输入的不是1,pass,print 执行完后,继续while
in the while
input a num: