码迷,mamicode.com
首页 > 编程语言 > 详细

[]Python][simple]Serialize data with Pickle and deserialize data from pickle

时间:2019-12-31 10:32:22      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:rom   friend   dump   with open   des   load   pen   ali   lod   

 

序列化

import pickle

friend = {"Dan": [20, "Lodon", 123123], "Mary" : [24, "Madi", 333333]}

with open("friend.dat", "wb") as f:
    pickle.dump(friend, f)

反序列化

with open("friend.dat", "rb") as f:
    obj = pickle.load(f)
     print(obj)

[]Python][simple]Serialize data with Pickle and deserialize data from pickle

标签:rom   friend   dump   with open   des   load   pen   ali   lod   

原文地址:https://www.cnblogs.com/jbite9057/p/12122818.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!