Tips and Traps¶
Make sure to use the mode
rb/wbwhen read/write pickle files.
import pickleSerialize a dict object into pickle.
with open("out.pp", "wb") as fout:
pickle.dump({"x": 1}, fout)Deserialize the dict from the file.
with open("out.pp", "rb") as fin:
dic = pickle.load(fin)
dic{'x': 1}