我有一个十六进制字符串的numpy数组(例如:['9','a','B']),希望将它们全部转换为0到255之间的整数。我知道的唯一方法是使用for循环并附加一个单独的numpy数组
import numpy as np
hexArray = np.array(['9', 'A', 'B'])
intArray = np.array([])
for value in hexArray:
intArray = np.append(intArray, [int(value, 16)])
print(intArray) # output: [ 9. 10. 11.]
有更好的方法吗
使用地图的备选方案:
具有阵列视图功能的矢量化方式-
计时
给定样本按
1000x
比例放大的设置使用列表理解:
输出:
相关问题 更多 >
编程相关推荐