numpy tostring() fromstring()

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zjm750617105/article/details/78391999

must specify the right dtype !!!

a
Out[54]: array([1, 2, 3])
b = a.tostring()
np.fromstring(b)
Out[52]: array([  4.94065646e-324,   9.88131292e-324,   1.48219694e-323]) #Wrong!
Out[56]: array([1, 2, 3])
type(a)
Out[57]: numpy.ndarray
type(a[0])
Out[58]: numpy.int64
np.fromstring(b, dtype=np.int64) # must use the right type!!!
Out[60]: array([1, 2, 3])

猜你喜欢

转载自blog.csdn.net/zjm750617105/article/details/78391999