转自:https://blog.csdn.net/u010041824/article/details/78391683
1.打开带有中文的pkl文件或者其他字符的文件不能用默认的ascii格式打开,需要指定编码格式:
import pickle # f = open('dict_word.pkl', 'rb') # for line in f: # print(line) word = pickle.load(open("word.pkl", 'rb'), encoding='utf-8') train = pickle.load(open("train.pkl", 'rb'),encoding='iso-8859-1')
如果是没有中文,那就不用设定编码格式