【发布时间】:2014-07-29 02:24:23
【问题描述】:
我正在尝试加载/usr/share/matplotlib/sample_data/goog.npy:
datafile = matplotlib.cbook.get_sample_data('goog.npy', asfileobj=False)
np.load(datafile)
在 Python 2.7 中没问题,但在 Python 3.4 中引发异常:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd4 in position 1: ordinal not in range(128)
我认为这与bytes/str/unicode Python 2 和 3 之间的不一致有关,但不知道如何解决。
问题:
- 如何在 Python 3 中从 Python 2 加载
.npy文件(NumPy 数据)?
【问题讨论】:
标签: python python-3.x numpy python-unicode