Reason: TXT is a UTF-8 code, so the code needs to be changed to UTF-8
1. Find the error code line:
with open('CNBC.txt') as file_ object:
2. Change the code to:
with open('CNBC.txt', encoding='utf-8') as file_ object:
Similar Posts:
- [Solved] UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x89 in position 0: invalid start byte
- [Solved] Python Numpy Data load error: Unicode error: unpicking a python object failed: Unicode decodeerror
- [Solved] UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa6 in position 9737: ill
- An error occurred when the idea was compiled: java.io.ioexception: cannot create empty file:
- After the JVM is started, setting the system property file.encoding again cannot affect the default encoding of the system & sun.jnu.encoding
- [Solved] Python error: UnicodeDecodeError:’gbk’ codec can’t decode byte 0xb0 in position 166: illegal multibyte sequence
- [Solved] Pandas Parses MovieLens 1M Dataset Error: UnicodeDecodeError
- [Solved] UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa5 in position 1508: illegal multibyte sequence
- [Solved] Java compilation error: unmapped character encoding GBK
- Non-ASCII character ‘\xe8’ in file xxx.py on line 8, but no encoding declared