[英]How to manipulate an array in python?
I have an array like:我有一个像这样的数组:
A=[[1,2,3,4,5,6,7,8,],[2,5,7,5,3,6,89,2],[22,44,55,77,88,34,44,66]]
I need them like:我需要它们:
C=[1,2,22] d=[2,5,44] e=[3,7,55]........ j=[8,2,66]
how to do it in python kindly help.如何在 python 中做到这一点,请帮助。
You can do this with zip:您可以使用 zip 执行此操作:
[[a,b,c] for a,b,c in zip(*A)]
You can use zip without the need for writing the craziness you are talking about.您可以使用 zip 而无需编写您正在谈论的疯狂。
[list(i) for i in zip(*A)]
Likewise同样地
name='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for n,i in enumerate(zip(*Arr)):
globals() [ str(name[n]) ]=i
Output Output
print(A) #[1,2,22]
print(B) #[2,5,44]
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.