一个可迭代对象中嵌套着一个可迭代对象
m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
n = [[2, 2, 2], [3, 3, 3], [4, 4, 4]]
z=zip(m,n)
for i,j in z:#因为可迭代对象中嵌套着可迭代对象,并且有两个元素 相当于嵌套的list [[1,2],[3,4]]
print(i,j)
[1, 2, 3] [2, 2, 2]
[4, 5, 6] [3, 3, 3]
[7, 8, 9] [4, 4, 4]
for i,j in list(range(10)):
print(i,j)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'int' object is not iterable
#对不可迭代对象无法使用
python3中zip中的数据只能操作一次,内存就会释放