小编Far*_*ari的帖子

如何在python 3中将二维数组转换为元组?

类型转换

我有一个尺寸为 667000 * 3 的 numpy 数组,我想将它转换为 667000 * 3 元组。

在较小的维度中,就像将 arr 转换为 t,其中:

arr= [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]

t= ((1,2,3),(4,5,6),(7,8,9),(10,11,12))
Run Code Online (Sandbox Code Playgroud)

我试过了 :

t = tuple((map(tuple, sub)) for sub in arr)   
Run Code Online (Sandbox Code Playgroud)

但没有用。

你能帮我在python 3中怎么做吗?

python arrays tuples type-conversion

4
推荐指数
1
解决办法
4889
查看次数

标签 统计

arrays ×1

python ×1

tuples ×1

type-conversion ×1