UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6

python 3以上版本使用pickle.load读取文件报UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6

只需要在打开的时候指定编码: encoding = 'iso-8859-1'   如下所示:

fo = open(file, 'rb')

dict = pickle.load(fo,encoding='iso-8859-1')

你可能感兴趣的:(UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6)