在numpy.fromstring中获取错误

时间:2017-07-12 20:12:11

标签: numpy

我正在尝试将此字符串'w'转换为空格,而不更改原始字符串'w'的含义。

import numpy as np
w="\x01\x02 \x01\x02"
results = np.fromstring(w, dtype=np.int16)
print results

我收到错误消息:

> File "prj1.py", line 7, in <module> 
> results = np.fromstring(w, dtype=np.int16)
> ValueError: string size must be a multiple of element size

有没有办法正确转换?

0 个答案:

没有答案