您好,登录后才能下订单哦!
import pickle
def sh(name):
print("hello,",name)
#序列化存储
info={'key':'mode',
'lis':'koud',
'olo':234,
'func':sh
}
f=open("text.txt","wb")
print(pickle.dumps(info)) #pickle序列化以二进制存储
f.write(pickle.dumps(info))
pickle.dump(info,f) #优化后的写法效果完全相同
f.close()
import pickle #只有在python语言里用
def sh(name): #序列化整个函数
print("hello3,",name)
print("hello4,",name)
f=open("text.txt","rb") #pickle反序列化读取的是二进制数据
data=pickle.loads(f.read())
data=pickle.load(f) #优化写法效果完全相同
print(data"func")
import shelve,datetime
#a=shelve.open("new_year")
name=["alex","jack","tomo"]
info={"age":22,"job":"it","name":"alex"}
date=datetime.datetime.now()
a["name"]=name
a["indo"]=info
a["date"]=date
a.close()
import shelve,datetime
a=shelve.open("new_year")
print(a.get("indo"))
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。