break用于完全结束一个循环,跳出循环体,执行循环后面的语句
# -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" count = 0 while count <=10: print('loop',count) if count == 4: break #结束整个循环 count +=1 print('End')
运行结果
continue用于终止本次循环,继续进行下一轮循环
break用于完全结束一个循环,跳出循环体,执行循环后面的语句
# -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" count = 0 while count <=10: print('loop',count) if count == 4: break #结束整个循环 count +=1 print('End')
运行结果
continue用于终止本次循环,继续进行下一轮循环