📜  保存和加载字典 python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.970000             🧑  作者: Mango

代码示例1
import pickle
dictionary_data = {"a": 1, "b": 2}
a_file = open("data.pkl", "wb")
pickle.dump(dictionary_data, a_file)
a_file.close()
a_file = open("data.pkl", "rb")
output = pickle.load(a_file)
print(output)
a_file.close()