1、break立即打断循环并且不再执行else
count = 0 while count <= 5: count += 1 if count == 3: break print("loop",count) else: print("循环执行完了") print("end")
2、while循环后会执行else
count = 0 while count <= 5: count += 1 if count == 3: pass print("loop",count) else: print("循环执行完了") print("end")
原文:https://www.cnblogs.com/ccqc/p/10129038.html