Python persistence
pickle--Python object serialization
对象序列化主要用于保存数据以及数据传输
pickle是Python的一个包,它能把Python object序列化成字节流。它是python独有的,非通用的
marshal是比pickle更原始的序列化模块。
dumps()序列化一个对象
loads()反序列化
如果需要控制序列化和反序列,可以分别创建Pickler和Unpickler对象
可pickle的types:
None, True, and False
integers, floating point numbers, complex numbers
strings, bytes, bytearrays
tuples, lists, sets, and dictionaries containing only picklable objects
functions defined at the top level of a module (using def, not lambda)
built-in functions defined at the top level of a module
classes that are defined at the top level of a module
instances of such classes whose dict or the result of calling getstate() is picklable (see section Pickling Class Instances for details).
shelve,python object persistence ,dictionary-like object.
shelf对象支持字典的所有方法
shelve模块是pickle的高级实现。

浙公网安备 33010602011771号