zip 拉链方法
例如:1.
print(list(zip(('a','n','c'),('1','2','3'))))
运行结果:
[('a', '1'), ('n', '2'), ('c', '3')] Process finished with exit code 0
2.
a = {'name':'abc','age':18,'address':'bj'} print(list(zip(a.keys(),a.values())))
运行结果:
[('name', 'abc'), ('age', 18), ('address', 'bj')] Process finished with exit code 0
3.
print(list(zip(('abcdefg'),('1234567'))))
运行结果:
[('a', '1'), ('b', '2'), ('c', '3'), ('d', '4'), ('e', '5'), ('f', '6'), ('g', '7')] Process finished with exit code 0