import pickle
創(chuàng)新互聯(lián)致力于網(wǎng)站設(shè)計(jì)制作、做網(wǎng)站,成都網(wǎng)站設(shè)計(jì),集團(tuán)網(wǎng)站建設(shè)等服務(wù)標(biāo)準(zhǔn)化,推過標(biāo)準(zhǔn)化降低中小企業(yè)的建站的成本,并持續(xù)提升建站的定制化服務(wù)水平進(jìn)行質(zhì)量交付,讓企業(yè)網(wǎng)站從市場(chǎng)競(jìng)爭(zhēng)中脫穎而出。 選擇創(chuàng)新互聯(lián),就選擇了安全、穩(wěn)定、美觀的網(wǎng)站建設(shè)服務(wù)!
def sh(name):
print("hello,",name)
#序列化存儲(chǔ)
info={'key':'mode',
'lis':'koud',
'olo':234,
'func':sh
}
f=open("text.txt","wb")
print(pickle.dumps(info)) #pickle序列化以二進(jìn)制存儲(chǔ)
f.write(pickle.dumps(info))
pickle.dump(info,f) #優(yōu)化后的寫法效果完全相同
f.close()
import pickle #只有在python語言里用
def sh(name): #序列化整個(gè)函數(shù)
print("hello3,",name)
print("hello4,",name)
f=open("text.txt","rb") #pickle反序列化讀取的是二進(jìn)制數(shù)據(jù)
data=pickle.loads(f.read())
data=pickle.load(f) #優(yōu)化寫法效果完全相同
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"))