solution0:
open the .txt file in notepad (default in windows), then choose the encoding method as "utf8", then save the file in this format.
solution0-1:
the pickle file in different python environment will also lead to this problem. For example, if xx.pickle is saved in python2. There will arise some problems when loading the pickle file in python3 environment.
soluntion1:
file=open(path,encoding='UTF-8',errors='ignore')
solution 2:
import codecs
fr = open(‘test.txt’)
The problem can be solved by changing to the following:
fr= codecs.open(‘test.txt’, ‘r’,encoding= u’utf-8’,errors=‘ignore’)