# eg1 print('eg2:') i = 1 while i <= 5: if i == 4: print('吃饱了,不吃了') break print(f'吃了第{i}个苹果') i += 1 # eg2 print('eg2:') i = 1 while i <= 5: if i == 3: print(f'大虫子,第{i}个不吃了') # 在continue之前一定要修改计数器,否则会陷入死循环 i += 1 continue print(f'吃了第{i}个苹果') i += 1
python中break和continue的使用例子
最新推荐文章于 2024-02-26 10:18:11 发布