What can be pickled and unpickled?
The following types can be pickled:
可以被序列化的类型有:
-
None
,True
, andFalse
-
integers, floating point numbers, complex numbers,整型、浮点型、复数
-
strings, bytes, bytearrays,字符串、比特类型、比特数组
-
tuples, lists, sets, and dictionaries containing only picklable objects,元组、列表、集合、字典,它们里面包含的内容也必须可以pickle
-
functions defined at the top level of a module (using
def
, notlambda
) -
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).
网友评论