比如a = [1, 2, 3], b = [4, 5, 6] 合并为[1, 4, 2, 5, 3, 6] 你觉得怎么写比较优雅?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
a = [1,2,3] b = [4,5,6] s = [] for i in zip(a,b):s.extend(list(i)) print s
[1, 4, 2, 5, 3, 6]
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]