2024-04-25 13:04:45 发布
网友
我想使用python将numpy数组更改为char数组,例如
a = np.arange(25).reshape([5,5])
如何更改数组?在
您可以使用astype方法更改numpy数组的数据类型。请尝试以下示例:
astype
import numpy as np a = np.arange(25).reshape([5,5]) a.dtype #check data type of array it should show int new = a.astype(str) #change data type of array to string new.dtype #Check the data type again it should show string
您可以使用
astype
方法更改numpy数组的数据类型。请尝试以下示例:相关问题 更多 >
编程相关推荐