import pickle
## 序列化-案例1
age = 19
## 文件不存在时会自动创建
with open(r'test01.txt', 'wb') as f:
pickle.dump(age, f)
## 反序列化-案例1
with open(r'test01.txt', 'rb') as f:
age = pickle.load(f)
print(age)
------------------------------------------------------------------
## 序列化-案例2
a = [19, 'liudana', "i love wangxiaojing", [185, 76]]
with open(r'test01.txt', 'wb') as f:
pickle.dump(a, f)
## 反序列化-案例2
with open(r'test01.txt', 'rb') as f:
s = pickle.load(f)
print(s)