Tips and Traps¶
- Make sure to use the mode
rb
/wb
when read/write pickle files.
In [1]:
import pickle
Serialize a dict object into pickle.
In [4]:
with open("out.pp", "wb") as fout:
pickle.dump({"x": 1}, fout)
Deserialize the dict from the file.
In [10]:
with open("out.pp", "rb") as fin:
dic = pickle.load(fin)
dic
Out[10]: