break 跳出整个循环(再也不干了)
continue 跳出这一次的循环(下一次真香)
举个例子
for i in 'YaoYee': if i == 'o': break print(i, end='') print('------') val = 5 while val>0: val -= 1 if val == 2: break print(val, end='') print('------') for i in 'YaoYee': if i == 'o': continue print(i, end='') print('------') val = 5 while val>0: val -= 1 if val == 2: continue print(val, end='') print('------') 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
输出如下:
Ya------
43------
YaYee------
4310------
参考资料:https://blog.csdn.net/YaoYee_21/article/details/119706082