注意:一定不能用np.save(path,dict)写入文件。。。内容会出错
用dict序列化与反序列化的操作:
dict的序列化与反序列化:
with open("word2int.txt", "wb") as f:
pickle.dump(word2int,f)
with open("word2int.txt", "rb+") as f:
d = pickle.load(f)
写文件:
d = dict(name='TSQ', age=18)
import pickle
with open("dict.file", "wb") as f:
pickle.dump(d, f)
读文件:
d = dict(name='TSQ', age=18)
import pickle
with open("dict.file", "wb") as f:
pickle.dump(d, f)
np.array的序列化与反序列化
np.save('vocmat', matrix)
data = np.load('vocmat')
最后
以上就是想人陪高山最近收集整理的关于dict和OrderDict写入文件dict的序列化与反序列化:np.array的序列化与反序列化的全部内容,更多相关dict和OrderDict写入文件dict内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复