【发布时间】:2020-04-17 21:10:19
【问题描述】:
python 3 无法读取我的文件。该文件是一个孟加拉语单词数据库。我写了以下代码:
x = open('c:\\BengaliWordList_112.txt').read()
代码显示以下错误:
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-12-0b3d4d6e7768> in <module>
----> 1 x = open('c:\\BengaliWordList_112.txt').read()
~\Anaconda3\lib\encodings\cp1252.py in decode(self, input, final)
21 class IncrementalDecoder(codecs.IncrementalDecoder):
22 def decode(self, input, final=False):
---> 23 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
24
25 class StreamWriter(Codec,codecs.StreamWriter):
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 28: character maps to <undefined>
【问题讨论】:
-
是的,它有帮助。谢谢!
标签: python string utf-8 character-encoding