with open(filename, 'rb') as f:
datadict = pickle.load(f,encoding='iso-8859-1')
解决
TypeError: ‘str’ does not support the buffer interface
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe8 in position 0: ordinal not in range(128)
首先应该指明用二进制方式('rb')打开文件,然后需要告诉pickle:how to convert Python bytestring data to Python 3 strings,The default is to try and decode all string data as ASCII(encoding='iso-8859-1')
datadict = pickle.load(f,encoding='iso-8859-1')
解决
TypeError: ‘str’ does not support the buffer interface
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe8 in position 0: ordinal not in range(128)
首先应该指明用二进制方式('rb')打开文件,然后需要告诉pickle:how to convert Python bytestring data to Python 3 strings,The default is to try and decode all string data as ASCII(encoding='iso-8859-1')