保存
def save_dict(data, name):
with open(name + '.pkl', 'wb') as f:
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
读取
# 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)
参考文献
[1]生成.pkl文件,读取.pkl文件的内容 https://blog.youkuaiyun.com/weixin_39450145/article/details/104910738