特色用法:实现行列互换
用法:
for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
print(item)
result...:
[(1, 'sugar')]
[(2, 'spice')]
[(3, 'everything nice')]
a = list(zip(range(3), ['fee', 'fi', 'fo',...print(a)
result:
[(0, 'fee'), (1, 'fi'), (2, 'fo')]
a = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
b = list(zip...result:
[(1, 2, 3), (4, 5, 6), (7, 8, 9)]
参考文献:https://docs.python.org/zh-cn/3/library/functions.html#zip