python 2 保存的pickle文件在python 3中直接用二进制读取会有问题,需要添加encoding='bytes'
存
f=open('output.txt','w')
pickle.dump(output,f,0)
f.close()
pickle.clear_memo()
f=open('image_original.txt','w')
pickle.dump(image_original,f,0)
f.close()
读
fr = open('output.txt','rb')
output = pickle.load(fr,encoding='bytes')
fr.close()
fr = open('image_original.txt','rb')
image_original = pickle.load(fr,encoding='bytes')
fr.close()