我正在使用来自这里的以下代码(略有修改):
import _pickle as cPickle
def unpickle(file):
fo = open(file, 'rb')
dict = cPickle.load(fo)
fo.close()
return dict
unpickle('data_batch_1')
当我运行这段代码时,假设我使用的是Python 3.5.2
,我会得到以下结果:
Traceback (most recent call last):
File "open_batch.py", line 10, in <module>
unpickle('data_batch_1')
File "open_batch.py", line 5, in unpickle
dict = cPickle.load(fo)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6: ordinal not in range(128)
我该如何解决这个问题?
谢谢。