我想像转换元组
t = [(4,10),(9,7),(11,2),(2,2)]
变成2D数组,例如:
a = [[4,10],[9,7],[11,2],[2,2]]
我试过了
a = []
for i in t:
a.append(np.asarray(i))
print a
有没有更简单的方法?
使用list
如下的理解:
>>> t = [(4,10),(9,7),(11,2),(2,2)]
>>> [list(item) for item in t]
[[4, 10], [9, 7], [11, 2], [2, 2]]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句