break退出当前循环

# -*- coding: utf-8 -*-
for i in range(10):
    for j  in range(20):
        if j >4:
            break
        else:
            print i,j

			
C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled/templates/t1.py
0 0
0 1
0 2
0 3
0 4
1 0
1 1
1 2
1 3
1 4
2 0
2 1
2 2
2 3
2 4
3 0
3 1
3 2
3 3
3 4
4 0
4 1
4 2
4 3
4 4
5 0
5 1
5 2
5 3
5 4
6 0
6 1
6 2
6 3
6 4
7 0
7 1
7 2
7 3
7 4
8 0
8 1
8 2
8 3
8 4
9 0
9 1
9 2
9 3
9 4

猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/85107705
今日推荐