|
发表于 2021-7-23 20:38:14
|
显示全部楼层
basic write and read of pickle module
- In [2]: import pickle
- In [3]: d = {'a': 100, 'b': 200}
- In [4]: pickle.dump?
- Signature: pickle.dump(obj, file, protocol=None, *, fix_imports=True)
- Docstring:
- Write a pickled representation of obj to the open file object file.
- This is equivalent to ``Pickler(file, protocol).dump(obj)``, but may
- be more efficient.
- ……
- In [6]: pickle.dump(obj = d, file = open('dict.pkl', 'wb'))
- In [7]: pickle.load(file=open('dict.pkl', 'rb'))
- Out[7]: {'a': 100, 'b': 200}
- In [8]:
复制代码 |
|