pickle
# 存储变量的文件的名字 filename = 'Day3-Data.data' if os.path.exists(filename): print("Already exist") with open(filename, 'rb') as load_data: r = pickle.load(load_data)# 加载数据 else: Data = Data() r = Data.getData(url=r'https://adventofcode.com/2020/day/3/input') with open(filename, 'wb') as save_data: pickle.dump(r, save_data)# 写入数据