首页 > 代码库 > while循环
while循环
例(1) count_1 = True while count_1: print(‘1‘) print(‘2‘) count_1 = False print(‘3‘) 例(2) count_1 = True while count_1: print(‘1‘) print(‘2‘) count_1 = False print(‘3‘) 例(3) count_1 = 1 count_2 = True while count_2: print(count_1) if count_1 == 100: count_2 = False count_1 +=1 print(‘end.....‘) 例(4) count_1 = 1 while count_1: print(count_1) if count_1 == 100: break #跳出当前循环 count_1 +=1 print(‘end.....‘) 例(5) while True: print(‘123‘) continue#结束本次循环跳到下一次循环 pritn(‘456‘) print(‘end.....‘)
例(3) count_1 = 0 while True: if count_1 == 6 or count_1 == 3: count_1 += 1 continue print(count_1) count_1 += 1 if count_1 == 10: break print(‘end.....‘)
while循环
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。