import os.path as osp
import pickle
save_file = osp.join(self.data_root, "ch7_cached.pkl")
if osp.exists(save_file) and not rebuild:
print("Using Cached file: {}".format(save_file))
self._data = pickle.load(open(save_file, "rb"))
else:
self._data = self.process_data()
with open(save_file, "wb") as f:
pickle.dump(self.data, f)
print("Cached file: {}".format(save_file))
创建文件前判断文件存在与否
最新推荐文章于 2022-10-17 20:42:57 发布