我正在实现这个 notebook在使用 Python 3.5.3 的 Windows 上,在 load_vectors() 调用中出现跟随错误。我尝试了不同的解决方案,但都没有奏效。
<ipython-input-86-dd4c123b0494> in load_vectors(loc)
1 def load_vectors(loc):
2 return (load_array(loc+'.dat'),
----> 3 pickle.load(open(loc+'_words.pkl','rb')),
4 pickle.load(open(loc+'_idx.pkl','rb')))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
最佳答案
我通过将整个 csv 文件复制并粘贴到文本中并通过以下方式阅读来解决了这个问题:
with open(self.path + "/review_collection.txt", "r", encoding="utf-8") as f:
read = f.read().splitlines()
for row in read:
print(row)
关于Python 3 统一码解码错误 : 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46046752/