高逼格用法:
a=[1,2,3]
b=[4,5,6,7]
1.当要对它进行遍历时:
a=[1,2,3] b=[4,5,6,7] for i,j in zip(a,b): print(i,j)
列表会依次对齐,超过的长度不会打印出来
2.若要多下标操作则要用:enumerate
a=[1,2,3] b=[4,5,6,7] for i,(q,p) in enumerate(zip(a,b)): print(i,q,p)
3.创建键值对:
a=[1,2,3] b=[4,5,6,7] dict=dict(zip(a,b)) print(dict)
结果
{1: 4, 2: 5, 3: 6}