python列表表达式能嵌套多重循环
>>> [(i,j) for i in range(4) for j in range(2)]
[(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1)]
以上这个列表表达式等价于
>>> k=[]
>>> for i in range(4):
for j in range(2):
k.append((i,j))
>>> k
[(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1)]