zip() python

zip 就是zip函数接受任意多个(包括0个和1个)序列作为参数,返回一个tuple列表

x = [1, 2, 3]

y = [4, 5, 6]

z = [7, 8, 9]
list(zip(x, y, z))
Out[33]: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
x = [1, 2, 3]
y = [4, 5, 6, 7]
list(zip(x, y, z))
Out[36]: [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
posted @ 2022-08-19 23:00  luoganttcc  阅读(14)  评论(0编辑  收藏  举报