ValueError: unsupported pickle protocol: 3
出现该问题说明是在python2环境下想打开原本在python3下pickle保存的文件
解决这个问题的方式是:在原先python3环境下保存的时候改变pickle.dump()中protocol 参数为2
比如:
path = './file.pkl'
with open(path,'wb') as f:
pickle.dump(centers,f,protocol =2)
这样就可以在python2 环境下再打开,不报错:
path = './file.pkl'
with open(path,'rb') as f:
the_file = pickle.load(f)
print(the_file)

被折叠的 条评论
为什么被折叠?



