UnicodeDecodeError:'charmap'编解码器无法解码位置Y处的字节X:字符映射到。
UnicodeDecodeError:'charmap'编解码器无法解码位置Y处的字节X:字符映射到。
我正在尝试使用Python 3程序对一个包含信息的文本文件进行一些操作。但是,在尝试读取文件时,我会遇到以下错误:
Traceback (most recent call last): File "SCRIPT LOCATION", line NUMBER, in 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 ``
admin 更改状态以发布 2023年5月25日
如果file = open(filename, encoding="utf-8")
不起作用,可以尝试使用file = open(filename, errors="ignore")
,如果你想移除不必要的字符。(文档)