【发布时间】:2022-09-29 16:38:11
【问题描述】:
我正在尝试让 Python 3 程序对充满信息的文本文件进行一些操作。但是,在尝试读取文件时出现以下错误:
Traceback (most recent call last):
File "SCRIPT LOCATION", line NUMBER, in <module>
text = file.read()
File "C:\Python31\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2907500: character maps to `<undefined>`
【问题讨论】:
-
对于同样的错误,这些解决方案帮助了我,solution of charmap error
-
请参阅Processing Text Files in Python 3 了解为什么会出现此错误。
标签: python python-3.x unicode file-io decode