流程控制-while循環
阿新 • • 發佈:2019-03-26
count bsp == while style spa color 是個 內容
while 條件:
結果
如果條件是真 則直接執?結果. 然後再次判斷條件. 直到條件是假. 停?循環
#計數 count = 1 while count <= 8: print("你是個混蛋") count = count + 1
break: 立刻跳出循環. 打斷的意思
#停止當前循環 while True: s = input("請開始噴:") if s == "q": break #停止當前循環 print("噴的內容是:"+ s)
continue: 停?本次循環, 繼續執?下?次循環.
#停止當前循環 while True: s = input("請開始噴:") if s == "q": break #停止當前循環 #過濾掉馬化騰 if "馬化騰" in s:#在xxx中出現了xx print("你輸入的內容不合適,情重新輸入") continue #停止本次循環,再從頭開始下一次循環 print("噴的內容是:"+ s)
流程控制-while循環