当前位置: 代码迷 >> 综合 >> python dict 保存为pickle格式
  详细解决方案

python dict 保存为pickle格式

热度:62   发布时间:2023-12-19 03:47:57.0

1. dict 保存为 pickle

mydict = {
    "1": 10, "3": 30}
with open("./data/medFile/test.pickle", "wb") as fp:   #Picklingpickle.dump(mydict, fp, protocol = pickle.HIGHEST_PROTOCOL)      
with open("./data/medFile/test.pickle", "rb") as fp:   #Picklingmydict = pickle.load(fp)     
mydict