Python如何优雅的交错合并两个列表
伊谢尔伦
伊谢尔伦 2017-04-17 14:28:20
0
11
1138

比如a = [1, 2, 3], b = [4, 5, 6]
合并为[1, 4, 2, 5, 3, 6]
你觉得怎么写比较优雅?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(11)
大家讲道理

a = [1,2,3]
b = [4,5,6]
s = []
for i in zip(a,b):s.extend(list(i))
print s

result:

[1, 4, 2, 5, 3, 6]

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template