赞
踩
https://numpy.org/doc/stable/reference/generated/numpy.ndarray.astype.html#numpy.ndarray.astype
ndarray.astype(dtype, order=‘K’, casting=‘unsafe’, subok=True, copy=True) 返回一个数组的拷贝,转换成指定的类型。
示例:
import numpy as np
x = np.array([100, 20, 254])
print('x = ', x)
y = x.astype("float32")
print('y = ', y)
输出:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。