在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


 

相关文章:

  • 2021-11-24
  • 2021-09-23
猜你喜欢
  • 2021-11-16
  • 2021-12-05
  • 2021-12-05
  • 2021-12-18
相关资源
相似解决方案