import:: import pickle doc:: pickle 用法 基于内存 dumps(): 保存 loads(): 读取 1import pickle2 3# 保存4num = pickle.dumps(42)5# 读取6pickle.loads(num) 基于文件 1- dump(): 保存2- load(): 读取 1import pickle2 3# 保存4with open(<file_path>, 'wb') as f:5 pickle.dump(data, f)6 7# 读取8with open (<file_path>, 'rb') as f:9 data = pickle.load(f)