1. 生成.pkl文件: (pickle.dump:把数据dump写入pkl文件)
def save_dict(data, name):
with open(name + '.pkl', 'wb') as f:
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
2. 读取.pkl文件的内容:(pickle.load:从pkl文件load加载数据)
# read aus
'''
conds_filepath = os.path.join(self._root, self._opt.aus_file)
self._conds = self._read_conds(conds_filepath)'''
def _read_conds(self, file_path):
with open(file_path, 'rb') as f:
return pickle.load(f)