您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。