Python報錯:UnicodeDecodeError: 'gbk' codec can't decode byte ...
python讀取檔案時提示:UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 82: illegal multibyte sequence
解決方法:
在檔案的右括號前面加上: , encoding='UTF-8'
例如:錯誤程式碼是:
in_file = open('AAA/%s.xml'%(ID))
改為如下:
in_file = open('AAA/%s.xml'%(ID), encoding='UTF-8')
相關文章
- Python3.7使用pip install xxxx報錯:UnicodeDecodeError: 'gbk' codec can't decode bytePythonUnicodeError
- pip install ... ERROR: UnicodeDecodeError: ‘gbk‘ codec can‘t decode/ python setup.py egg_info CheckErrorUnicodePython
- Python讀取檔案時出現UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position xx: 解決方案PythonUnicodeError
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 0: invalid continuation byteUnicodeError
- pipenv install error UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in positionErrorUnicode
- PIP3安裝報錯nicodeDecodeError: 'ascii' codec can't decode byte 0xc3ErrorASCII
- python在用pandas對csv檔案處理的時候報UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb6。。。的錯誤PythonUnicodeError
- Python——UnicodeEncodeError: 'ascii' codec can't encode/decode charactersPythonUnicodeErrorASCII
- tensorflow讀取圖片時出現錯誤UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid sUnicodeError
- PyMySQL 獲取資料 'utf-8' codec can't decode byte 0xed in position 2: 錯誤MySql
- 【python爬蟲】用selenium爬時報錯UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\u2022‘Python爬蟲UnicodeError
- Python讀取csv檔案出現解碼錯誤UnicodeDecodeError: ‘utf-8‘ codec can‘t decodPythonUnicodeError
- python cx_Oracle: UnicodeEncodeError: 'ascii' codec can't encode charactersPythonOracleUnicodeErrorASCII
- day1 UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 2490: illegal multi...UnicodeError
- Python3解決UnicodeEncodeError: 'ascii' codec can't encode characters in position 0PythonUnicodeErrorASCII
- python str與byte轉換 encode decodePython
- eslint --fix 報錯 can't not find modulesEsLint
- Python報UnicodeDecodeErrorPythonUnicodeError
- MYSQL報1022錯誤:Can't write;duplicate key in table '.....'MySql
- 小程式真機報錯errMsg: “hideLoading:fail:toast can‘t be found“ ?IDEAIAST
- Dart: 開源了一個支援 stream 介面的 GBK codec, fast_gbkDartAST
- Django2.2 報錯:UnicodeDecodeError 解決方法DjangoUnicodeError
- 完美解決stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.ErrorPython
- GTID複製報錯處理:Last_Error: Error 'Can't drop database 'test';ASTErrorDatabase
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- Mac電腦下使用Socket報錯socket丟擲Can’t assign requested address解決Mac
- [mac pip錯誤]Can't connect to HTTPS URL because the SSL module is not availableMacHTTPAI
- TypeError: can‘t concat str to bytesError
- Can't open file: (errno: 24)
- mysql 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- Can't Connect to MySQL Server on IP Address (10061) 錯誤的解決方案MySqlServer
- 報錯indexerror: tensors used as indices must be long, byte or bool tensorsIndexError
- Mongoose can't update timestampGo
- Supervisor 解決 can't find command *
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock錯誤MySqlServer
- OSError: [E050] Can‘t find model ‘en_core_web_sm‘. It doesn‘t seem to be a shortcut link, a Python pErrorWebPython
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- multiprocessing pool AttributeError: Can't get attribute 'func'Error