Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 个列表,{1,2,3,4,5}并且{a,b,c,d,e}. 我想结束{{1,a},{2,b},{3,c},{4,d},{5,e}}。
{1,2,3,4,5}
{a,b,c,d,e}
{{1,a},{2,b},{3,c},{4,d},{5,e}}
这个怎么样:
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}]