![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 # -------------------------- 2 import pickle 3 # dic= {'k1':'v1','k2':'v2','k3':'v3'} 4 # str_dic=pickle.dumps(dic) 5 # print(str_dic) #打印的是bytes类型的二进制内容 6 # 7 # dic2 = pickle.loads(str_dic) 8 # print(dic2) #有吧字典给转换回来了 9 10 import time 11 struct_time = time.localtime(1000000000) 12 print(struct_time) 13 f = open('pickle_file','wb') 14 pickle.dump(struct_time,f) 15 f.close() 16 17 f = open('pickle_file','rb') 18 struct_time2 = pickle.load(f) 19 print(struct_time.tm_year)