我有2个列表, {1,2,3,4,5}{a,b,c,d,e} 我想以{{1,a},{2,b},{3,c},{4,d},{5,e}}结尾。

===============>>#1 票数:0

这个怎么样:

l1 = {1, 2, 3, 4, 5};
l2 = {a, b, c, d, e};

Partition[Riffle[l1, l2], 2]
{{1, a}, {2, b}, {3, c}, {4, d}, {5, e}}

或者,您可以尝试

l1 = {1, 2, 3, 4, 5};
l2 = {a, b, c, d, e};

Transpose[{l1, l2}]
{{1, a}, {2, b}, {3, c}, {4, d}, {5, e}}

  ask by ryerex translate from so

未解决问题?本站智能推荐: