欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

numpy tostring() fromstring(),numpyfromstring

来源: javaer 分享于  点击 20025 次 点评:263

numpy tostring() fromstring(),numpyfromstring


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])

######### when read string from numpy (python3) ########
a[1] + 'haha'  ## error
str(a[1]) + 'haha'  ### correct

相关文章

    暂无相关文章

用户点评