访次: AmazingCounters.com 次

简单的嵌套循环

 1 嵌套循环
 2 for i in range(10):
 3 if i > 5:
 4 #countinue 跳出本次循环
 5 #break 跳出这一层整个循环
 6 #continue
 7 break
 8 print(i)
 9 ----------------------------------------------
10 #输出:
11 0
12 1
13 2
14 3
15 4
16 5
17 ------------------------------------------------------------------------------
18 for i in range(10):
19 if i < 5:
20 #countinue 跳出本次循环
21 #break 跳出这一层的整个循环
22 continue
23 #break
24 print(i)
25 ----------------------------------------------
26 5
27 6
28 7
29 8
30 9
31 ----------------------------------------------------
32 for j in range(5):
33 for i in range(10):
34 if i < 5:
35 #countinue 跳出本次循环
36 #break 跳出这一层的整个循环
37 continue
38 #break
39 if j>3:
40 break
41 print(i)

 

posted @ 2016-01-11 18:15  IT老登  阅读(227)  评论(0编辑  收藏  举报
访次: AmazingCounters.com 次