Python 循环终止语句

在Python循环终止语句有三种:

1、break

      break用于退出本层循环

     示例如下:

    

while True:
    print "123"
    break
    print "456"


2、continue

      continue为退出本次循环,继续下次循环

     示例如下:

     

while True:
    print "123"
    continue
    print "456"

3、自定义标记  Tag

      自已定义一个标记为True或False

     示例代码:

     

Tag =  True
while True:
    print "123"
    print "456"
    Tag = False


原文地址:https://www.cnblogs.com/liuxiaowei/p/7163459.html