美文网首页
Python跳出多重循环的方法

Python跳出多重循环的方法

作者: shuff1e | 来源:发表于2018-03-20 16:16 被阅读199次

    python中居然没有跳出多层循环的标准语法

    [root@shuffle-dev py_test]$ vim sf_breakN.py       
      1 #!/usr/bin/env python
      2 # -*- coding: utf-8 -*-
      3 
      4 for i in range(1,5):
      5     for j in range(1,5):
      6         for k in range(1,5):
      7             if i==j==k==2:
      8                 break    #break1                                                                         
      9             else:
     10                 print i,'---',j,'---',k
     11         else:
     12             continue
     13         break    #break2
     14     else:
     15         continue
     16     break    #break 3
    

    相关文章

      网友评论

          本文标题:Python跳出多重循环的方法

          本文链接:https://www.haomeiwen.com/subject/vsejqftx.html