[Solved] Python Error: UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xad in position…

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: