python进阶--哪些python对象可以pickle序列化

What can be pickled and unpickled?

The following types can be pickled:
可以被序列化的类型有:

  • None, True, and False

  • 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, 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).

你可能感兴趣的:(python进阶--哪些python对象可以pickle序列化)