001、
>>> a = [1, 2, 3] >>> b = [4, 5, 6] >>> c = [7, 8, 9, 10, 11] ## 测试列表 >>> list(zip(a,b)) [(1, 4), (2, 5), (3, 6)] >>> list(zip(a,c)) ## 返回列表元祖 [(1, 7), (2, 8), (3, 9)]
002、
>>> name = ('jack', 'alex', 'sony', 'joey') >>> age = (25, 28, 21, 30) >>> for a, n in zip(name, age): ... print(a, n) ... jack 25 alex 28 sony 21 joey 30
003、
>>> a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> list(zip(*a)) ## 可用于二维列表的转置 [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
标签:25,21,zip,python,list,列表,##,用法 From: https://www.cnblogs.com/liujiaxin2018/p/17476150.html