本文由 大侠(AhcaoZhu)原创,转载请声明。
链接: https://blog.csdn.net/Ahcao2008
一图看懂 pickle 模块:用于序列化和反序列化, 资料整理+笔记(大全)
- 摘要
- 说明
- 模块图
- 类关系图
- 模块全展开
- 【pickle】
- 统计
- 常量
- 模块
- 函数
- 17 _getattribute(obj, name)
- 18 whichmodule(obj, name)
- 19 encode_long(x)
- 20 decode_long(data)
- 21 _dump(obj, file, protocol=None, *, fix_imports=True)
- 22 _dumps(obj, protocol=None, *, fix_imports=True)
- 23 _load(file, *, fix_imports=True, encoding='ASCII', errors='strict')
- 24 _loads(s, *, fix_imports=True, encoding='ASCII', errors='strict')
- 25 _test()
- 类
- 26 function
- 27 itertools.islice
- 28 functools.partial
- 29 _pickle.PickleError
- 30 _pickle.PicklingError
- 31 _pickle.UnpicklingError
- 32 pickle._Stop
- 33 pickle._Framer
- 34 pickle._Unframer
- 35 pickle._Pickler
- data
- method
- 2 clear_memo(self)
- 3 dump(self, obj)
- 4 get(self, i)
- 5 memoize(self, obj)
- 6 persistent_id(self, obj)
- 7 put(self, idx)
- 8 save(self, obj, save_persistent_id=True)
- 9 save_bool(self, obj)
- 10 save_bytes(self, obj)
- 11 save_dict(self, obj)
- 12 save_float(self, obj)
- 13 save_frozenset(self, obj)
- 14 save_global(self, obj, name=None)
- 15 save_list(self, obj)
- 16 save_long(self, obj)
- 17 save_none(self, obj)
- 18 save_pers(self, pid)
- 19 save_reduce(self, func, args, state=None, listitems=None,
- 20 save_set(self, obj)
- 21 save_str(self, obj)
- 22 save_tuple(self, obj)
- 23 save_type(self, obj)
- 36 pickle._Unpickler
- data
- method
- 2 find_class(self, module, name)
- 3 get_extension(self, code)
- 4 load(self)
- 5 load_additems(self)
- 6 load_append(self)
- 7 load_appends(self)
- 8 load_binbytes(self)
- 9 load_binbytes8(self)
- 10 load_binfloat(self)
- 11 load_binget(self)
- 12 load_binint(self)
- 13 load_binint1(self)
- 14 load_binint2(self)
- 15 load_binpersid(self)
- 16 load_binput(self)
- 17 load_binstring(self)
- 18 load_binunicode(self)
- 19 load_binunicode8(self)
- 20 load_build(self)
- 21 load_dict(self)
- 22 load_dup(self)
- 23 load_empty_dictionary(self)
- 24 load_empty_list(self)
- 25 load_empty_set(self)
- 26 load_empty_tuple(self)
- 27 load_ext1(self)
- 28 load_ext2(self)
- 29 load_ext4(self)
- 30 load_false(self)
- 31 load_float(self)
- 32 load_frame(self)
- 33 load_frozenset(self)
- 34 load_get(self)
- 35 load_global(self)
- 36 load_inst(self)
- 37 load_int(self)
- 38 load_list(self)
- 39 load_long(self)
- 40 load_long1(self)
- 41 load_long4(self)
- 42 load_long_binget(self)
- 43 load_long_binput(self)
- 44 load_mark(self)
- 45 load_memoize(self)
- 46 load_newobj(self)
- 47 load_newobj_ex(self)
- 48 load_none(self)
- 49 load_obj(self)
- 50 load_persid(self)
- 51 load_pop(self)
- 52 load_pop_mark(self)
- 53 load_proto(self)
- 54 load_put(self)
- 55 load_reduce(self)
- 56 load_setitem(self)
- 57 load_setitems(self)
- 58 load_short_binbytes(self)
- 59 load_short_binstring(self)
- 60 load_short_binunicode(self)
- 61 load_stack_global(self)
- 62 load_stop(self)
- 63 load_string(self)
- 64 load_true(self)
- 65 load_tuple(self)
- 66 load_tuple1(self)
- 67 load_tuple2(self)
- 68 load_tuple3(self)
- 69 load_unicode(self)
- 70 persistent_load(self, pid)
- 71 pop_mark(self)
- 37 _pickle.Pickler
- 38 _pickle.Unpickler
- 内嵌函数或方法
- 私有或局部
- 剩余
- 【sys】
- 【re】
- 【io】
- 【codecs】
- 【_compat_pickle】
- 统计
- 常量
- 【_pickle】
- 统计
- 常量
- 类
- 内嵌函数或方法
摘要
全文介绍系统内置 pickle 模块、函数、类及类的方法和属性。
它通过代码抓取并经AI智能翻译和人工校对。
是一部不可多得的权威字典类工具书。它是系列集的一部分。后续陆续发布、敬请关注。【原创:AhcaoZhu大侠】
说明
序列化模块 pickle, 反序列化模块 cPickle,python后续版本命名规范化后,反序列化模块为 _pickle。
由于两个模块具有较强相关性,故合为一篇文章,不再单独成文。
模块图
pickle
◆sys
◆re
◆io
◆codecs
_compat_pickle
_pickle
类关系图
◆object
◆BaseException
◆Exception
_pickle.PickleError
_pickle.PicklingError
_pickle.UnpicklingError
pickle._Stop
_pickle.Pickler
_pickle.Unpickler
pickle._Framer
pickle._Pickler
pickle._Unframer
pickle._Unpickler
模块全展开
【pickle】
pickle, fullname=pickle, file=pickle.py
创建Python对象的可移植序列化表示。
有关注册自定义pickler的机制,请参阅模块copyreg。
请参阅模块pickletools源代码以获得广泛的注释。
类:
Pickler
Unpickler
函数:
dump(object, file)
dumps(object) -> string
load(file) -> object
loads(string) -> object
杂项:
__version__
format_version
compatible_formats
统计
序号 | 类别 | 数量 |
---|---|---|
1 | int | 3 |
4 | str | 6 |
5 | tuple | 1 |
6 | list | 3 |
8 | dict | 5 |
9 | module | 5 |
10 | class | 13 |
11 | function | 9 |
12 | builtin_function_or_method | 6 |
13 | residual | 70 |
14 | system | 9 |
15 | private | 16 |
16 | all | 121 |
常量
int
1 maxsize 9223372036854775807
2 HIGHEST_PROTOCOL 4
3 DEFAULT_PROTOCOL 3
str
4 format_version 4.0
tuple
5 bytes_types (<class ‘bytes’>, <class ‘bytearray’>)
list
6 compatible_formats [‘1.0’, ‘1.1’, ‘1.2’, ‘1.3’, ‘2.0’, ‘3.0’, ‘4.0’]
7 _tuplesize2code [b’)‘, b’\x85’, b’\x86’, b’\x87’]
dict
8 dispatch_table {<class ‘complex’>: <function pickle_complex at 0x0000000002AFCB88>, <class ‘re.Pattern’>: <function _pickle at 0x000000…
9 _extension_registry {}
10 _inverted_registry {}
11 _extension_cache {}
模块
12 sys
sys, fullname=sys, file=
13 re
re, fullname=re, file=re.py
14 io
io, fullname=io, file=io.py
15 codecs
codecs, fullname=codecs, file=codecs.py
16 _compat_pickle
_compat_pickle, fullname=_compat_pickle, file=_compat_pickle.py
函数
17 _getattribute(obj, name)
_getattribute(obj, name), module=pickle, line:289 at pickle.py
18 whichmodule(obj, name)
whichmodule(obj, name), module=pickle, line:302 at pickle.py
找到对象所属的模块。
19 encode_long(x)
encode_long(x), module=pickle, line:319 at pickle.py
编码一个长到二补的小端二进制字符串。
注意,0是一个特殊情况,返回一个空字符串,用于在LONG1 pickle上下文中保存一个字节。
>>> encode_long(0)
b''
>>> encode_long(255)
b'\xff\x00'
>>> encode_long(32767)
b'\xff\x7f'
>>> encode_long(-256)
b'\x00\xff'
>>> encode_long(-32768)
b'\x00\x80'
>>> encode_long(-128)
b'\x80'
>>> encode_long(127)
b'\x7f'
20 decode_long(data)
decode_long(data), module=pickle, line:349 at pickle.py
从二补小端二进制字符串解码一个长字符串。
>>> decode_long(b'')
0
>>> decode_long(b"\xff\x00")
255
>>> decode_long(b"\xff\x7f")
32767
>>> decode_long(b"\x00\xff")
-256
>>> decode_long(b"\x00\x80")
-32768
>>> decode_long(b"\x80")
-128
>>> decode_long(b"\x7f")
127
21 _dump(obj, file, protocol=None, *, fix_imports=True)
_dump(obj, file, protocol=None, *, fix_imports=True), module=pickle, line:1584 at pickle.py
22 _dumps(obj, protocol=None, *, fix_imports=True)
_dumps(obj, protocol=None, *, fix_imports=True), module=pickle, line:1587 at pickle.py
23 _load(file, *, fix_imports=True, encoding=‘ASCII’, errors=‘strict’)
_load(file, *, fix_imports=True, encoding=‘ASCII’, errors=‘strict’), module=pickle, line:1594 at pickle.py
24 _loads(s, *, fix_imports=True, encoding=‘ASCII’, errors=‘strict’)
_loads(s, *, fix_imports=True, encoding=‘ASCII’, errors=‘strict’), module=pickle, line:1598 at pickle.py
25 _test()
_test(), module=pickle, line:1623 at pickle.py
类
26 function
function, function, module=builtins
创建一个函数对象。
27 itertools.islice
islice, itertools.islice, module=itertools
28 functools.partial
partial, functools.partial, module=functools, line:234 at functools.py
29 _pickle.PickleError
PickleError, _pickle.PickleError, module=_pickle
30 _pickle.PicklingError
PicklingError, _pickle.PicklingError, module=_pickle
31 _pickle.UnpicklingError
UnpicklingError, _pickle.UnpicklingError, module=_pickle
32 pickle._Stop
_Stop, pickle._Stop, module=pickle
33 pickle._Framer
_Framer, pickle._Framer, module=pickle
method
1 commit_frame(self, force=False)
kind=method class=_Framer objtype=function line:201 at …\pickle.py
2 end_framing(self)
kind=method class=_Framer objtype=function line:196 at …\pickle.py
3 start_framing(self)
kind=method class=_Framer objtype=function line:193 at …\pickle.py
4 write(self, data)
kind=method class=_Framer objtype=function line:225 at …\pickle.py
5 write_large_bytes(self, header, payload)
kind=method class=_Framer objtype=function line:231 at …\pickle.py
34 pickle._Unframer
_Unframer, pickle._Unframer, module=pickle
method
1 load_frame(self, frame_size)
kind=method class=_Unframer objtype=function line:280 at …\pickle.py
2 read(self, n)
kind=method class=_Unframer objtype=function line:254 at …\pickle.py
3 readline(self)
kind=method class=_Unframer objtype=function line:267 at …\pickle.py
35 pickle._Pickler
_Pickler, pickle._Pickler, module=pickle
data
1 dispatch={<class ‘NoneType’>: <function _Pickler.save_none at 0x00000000038F8438>, <class… kind:data type:dict class:<class ‘pickle._Pickler’>
method
2 clear_memo(self)
kind=method class=_Pickler objtype=function line:416 at …\pickle.py
清除pickler的“备忘录”。
memo是一种数据结构,它记住 pickler 已经看过哪些对象,因此共享或递归对象是根据引用而不是根据值进行pickle的。
这种方法在重复使用 pickler 时很有用。
3 dump(self, obj)
kind=method class=_Pickler objtype=function line:426 at …\pickle.py
将obj的pickle表示写入打开的文件。
4 get(self, i)
kind=method class=_Pickler objtype=function line:476 at …\pickle.py
5 memoize(self, obj)
kind=method class=_Pickler objtype=function line:441 at …\pickle.py
在memo中存储一个对象。
6 persistent_id(self, obj)
kind=method class=_Pickler objtype=function line:551 at …\pickle.py
7 put(self, idx)
kind=method class=_Pickler objtype=function line:464 at …\pickle.py
8 save(self, obj, save_persistent_id=True)
kind=method class=_Pickler objtype=function line:485 at …\pickle.py
9 save_bool(self, obj)
kind=method class=_Pickler objtype=function line:673 at …\pickle.py
10 save_bytes(self, obj)
kind=method class=_Pickler objtype=function line:718 at …\pickle.py
11 save_dict(self, obj)
kind=method class=_Pickler objtype=function line:852 at …\pickle.py
12 save_float(self, obj)
kind=method class=_Pickler objtype=function line:711 at …\pickle.py
13 save_frozenset(self, obj)
kind=method class=_Pickler objtype=function line:920 at …\pickle.py
14 save_global(self, obj, name=None)
kind=method class=_Pickler objtype=function line:943 at …\pickle.py
15 save_list(self, obj)
kind=method class=_Pickler objtype=function line:812 at …\pickle.py
16 save_long(self, obj)
kind=method class=_Pickler objtype=function line:680 at …\pickle.py
17 save_none(self, obj)
kind=method class=_Pickler objtype=function line:669 at …\pickle.py
18 save_pers(self, pid)
kind=method class=_Pickler objtype=function line:555 at …\pickle.py
19 save_reduce(self, func, args, state=None, listitems=None,
kind=method class=_Pickler objtype=function line:567 at …\pickle.py
20 save_set(self, obj)
kind=method class=_Pickler objtype=function line:896 at …\pickle.py
21 save_str(self, obj)
kind=method class=_Pickler objtype=function line:738 at …\pickle.py
22 save_tuple(self, obj)
kind=method class=_Pickler objtype=function line:761 at …\pickle.py
23 save_type(self, obj)
kind=method class=_Pickler objtype=function line:1009 at …\pickle.py
36 pickle._Unpickler
_Unpickler, pickle._Unpickler, module=pickle
data
1 dispatch={128: <function _Unpickler.load_proto at 0x00000000038F8EE8>, 149: <function _Un… kind:data type:dict class:<class ‘pickle._Unpickler’>
method
2 find_class(self, module, name)
kind=method class=_Unpickler objtype=function line:1419 at …\pickle.py
3 get_extension(self, code)
kind=method class=_Unpickler objtype=function line:1403 at …\pickle.py
4 load(self)
kind=method class=_Unpickler objtype=function line:1063 at …\pickle.py
从打开的文件中读取pickle对象表示。
返回文件中指定的重构对象层次结构。
5 load_additems(self)
kind=method class=_Unpickler objtype=function line:1535 at …\pickle.py
6 load_append(self)
kind=method class=_Unpickler objtype=function line:1495 at …\pickle.py
7 load_appends(self)
kind=method class=_Unpickler objtype=function line:1502 at …\pickle.py
8 load_binbytes(self)
kind=method class=_Unpickler objtype=function line:1225 at …\pickle.py
9 load_binbytes8(self)
kind=method class=_Unpickler objtype=function line:1253 at …\pickle.py
10 load_binfloat(self)
kind=method class=_Unpickler objtype=function line:1193 at …\pickle.py
11 load_binget(self)
kind=method class=_Unpickler objtype=function line:1459 at …\pickle.py
12 load_binint(self)
kind=method class=_Unpickler objtype=function line:1155 at …\pickle.py
13 load_binint1(self)
kind=method class=_Unpickler objtype=function line:1159 at …\pickle.py
14 load_binint2(self)
kind=method class=_Unpickler objtype=function line:1163 at …\pickle.py
15 load_binpersid(self)
kind=method class=_Unpickler objtype=function line:1127 at …\pickle.py
16 load_binput(self)
kind=method class=_Unpickler objtype=function line:1476 at …\pickle.py
17 load_binstring(self)
kind=method class=_Unpickler objtype=function line:1216 at …\pickle.py
18 load_binunicode(self)
kind=method class=_Unpickler objtype=function line:1237 at …\pickle.py
19 load_binunicode8(self)
kind=method class=_Unpickler objtype=function line:1245 at …\pickle.py
20 load_build(self)
kind=method class=_Unpickler objtype=function line:1546 at …\pickle.py
21 load_dict(self)
kind=method class=_Unpickler objtype=function line:1320 at …\pickle.py
22 load_dup(self)
kind=method class=_Unpickler objtype=function line:1450 at …\pickle.py
23 load_empty_dictionary(self)
kind=method class=_Unpickler objtype=function line:1302 at …\pickle.py
24 load_empty_list(self)
kind=method class=_Unpickler objtype=function line:1298 at …\pickle.py
25 load_empty_set(self)
kind=method class=_Unpickler objtype=function line:1306 at …\pickle.py
26 load_empty_tuple(self)
kind=method class=_Unpickler objtype=function line:1282 at …\pickle.py
27 load_ext1(self)
kind=method class=_Unpickler objtype=function line:1388 at …\pickle.py
28 load_ext2(self)
kind=method class=_Unpickler objtype=function line:1393 at …\pickle.py
29 load_ext4(self)
kind=method class=_Unpickler objtype=function line:1398 at …\pickle.py
30 load_false(self)
kind=method class=_Unpickler objtype=function line:1136 at …\pickle.py
31 load_float(self)
kind=method class=_Unpickler objtype=function line:1189 at …\pickle.py
32 load_frame(self)
kind=method class=_Unpickler objtype=function line:1111 at …\pickle.py
33 load_frozenset(self)
kind=method class=_Unpickler objtype=function line:1310 at …\pickle.py
34 load_get(self)
kind=method class=_Unpickler objtype=function line:1454 at …\pickle.py
35 load_global(self)
kind=method class=_Unpickler objtype=function line:1373 at …\pickle.py
36 load_inst(self)
kind=method class=_Unpickler objtype=function line:1344 at …\pickle.py
37 load_int(self)
kind=method class=_Unpickler objtype=function line:1144 at …\pickle.py
38 load_list(self)
kind=method class=_Unpickler objtype=function line:1315 at …\pickle.py
39 load_long(self)
kind=method class=_Unpickler objtype=function line:1167 at …\pickle.py
40 load_long1(self)
kind=method class=_Unpickler objtype=function line:1174 at …\pickle.py
41 load_long4(self)
kind=method class=_Unpickler objtype=function line:1180 at …\pickle.py
42 load_long_binget(self)
kind=method class=_Unpickler objtype=function line:1464 at …\pickle.py
43 load_long_binput(self)
kind=method class=_Unpickler objtype=function line:1483 at …\pickle.py
44 load_mark(self)
kind=method class=_Unpickler objtype=function line:1570 at …\pickle.py
45 load_memoize(self)
kind=method class=_Unpickler objtype=function line:1490 at …\pickle.py
46 load_newobj(self)
kind=method class=_Unpickler objtype=function line:1358 at …\pickle.py
47 load_newobj_ex(self)
kind=method class=_Unpickler objtype=function line:1365 at …\pickle.py
48 load_none(self)
kind=method class=_Unpickler objtype=function line:1132 at …\pickle.py
49 load_obj(self)
kind=method class=_Unpickler objtype=function line:1351 at …\pickle.py
50 load_persid(self)
kind=method class=_Unpickler objtype=function line:1118 at …\pickle.py
51 load_pop(self)
kind=method class=_Unpickler objtype=function line:1439 at …\pickle.py
52 load_pop_mark(self)
kind=method class=_Unpickler objtype=function line:1446 at …\pickle.py
53 load_proto(self)
kind=method class=_Unpickler objtype=function line:1104 at …\pickle.py
54 load_put(self)
kind=method class=_Unpickler objtype=function line:1469 at …\pickle.py
55 load_reduce(self)
kind=method class=_Unpickler objtype=function line:1432 at …\pickle.py
56 load_setitem(self)
kind=method class=_Unpickler objtype=function line:1520 at …\pickle.py
57 load_setitems(self)
kind=method class=_Unpickler objtype=function line:1528 at …\pickle.py
58 load_short_binbytes(self)
kind=method class=_Unpickler objtype=function line:1267 at …\pickle.py
59 load_short_binstring(self)
kind=method class=_Unpickler objtype=function line:1261 at …\pickle.py
60 load_short_binunicode(self)
kind=method class=_Unpickler objtype=function line:1272 at …\pickle.py
61 load_stack_global(self)
kind=method class=_Unpickler objtype=function line:1380 at …\pickle.py
62 load_stop(self)
kind=method class=_Unpickler objtype=function line:1576 at …\pickle.py
63 load_string(self)
kind=method class=_Unpickler objtype=function line:1206 at …\pickle.py
64 load_true(self)
kind=method class=_Unpickler objtype=function line:1140 at …\pickle.py
65 load_tuple(self)
kind=method class=_Unpickler objtype=function line:1277 at …\pickle.py
66 load_tuple1(self)
kind=method class=_Unpickler objtype=function line:1286 at …\pickle.py
67 load_tuple2(self)
kind=method class=_Unpickler objtype=function line:1290 at …\pickle.py
68 load_tuple3(self)
kind=method class=_Unpickler objtype=function line:1294 at …\pickle.py
69 load_unicode(self)
kind=method class=_Unpickler objtype=function line:1233 at …\pickle.py
70 persistent_load(self, pid)
kind=method class=_Unpickler objtype=function line:1099 at …\pickle.py
71 pop_mark(self)
kind=method class=_Unpickler objtype=function line:1093 at …\pickle.py
37 _pickle.Pickler
Pickler, _pickle.Pickler, module=_pickle
这需要一个二进制文件来写入pickle数据流。
可选参数*protocol*告诉pickler使用给定的协议;支持的协议类型为:0、1、2、3、4。
默认协议为3;为Python 3设计的向后不兼容协议。
指定负协议版本将选择支持的最高协议版本。使用的协议越高级,读取生成的pickle所需的Python版本就越新。
*file*参数必须有一个write()方法,该方法接受单个字节的论点。
因此,它可以是为二进制文件打开的文件对象写作,是一种爱。BytesIO实例,或任何其他满足的自定义对象这个接口。
如果*fix_imports*为True且protocol小于3,pickle将尝试将新的Python 3名称映射到Python中使用的旧模块名称2,
这样pickle数据流就可以用Python 2读取。
data
1 bin=<member ‘bin’ of ‘_pickle.Pickler’ objects> kind:data type:member_descriptor class:<class ‘_pickle.Pickler’>
2 dispatch_table=<member ‘dispatch_table’ of ‘_pickle.Pickler’ objects> kind:data type:member_descriptor class:<class ‘_pickle.Pickler’>
3 fast=<member ‘fast’ of ‘_pickle.Pickler’ objects> kind:data type:member_descriptor class:<class ‘_pickle.Pickler’>
4 memo=<attribute ‘memo’ of ‘_pickle.Pickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Pickler’>
5 persistent_id=<attribute ‘persistent_id’ of ‘_pickle.Pickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Pickler’>
method
6 clear_memo()
kind=method class=Pickler objtype=method_descriptor
清除pickler的“备忘录”。
memo是一种数据结构,它记住pickle器已经看过哪些对象,因此共享或递归对象是根据引用而不是根据值进行pickle的。
这种方法在重复使用酸洗器时很有用。
7 dump()
kind=method class=Pickler objtype=method_descriptor
将给定对象的pickle表示写入打开的文件。
38 _pickle.Unpickler
Unpickler, _pickle.Unpickler, module=_pickle
这需要一个二进制文件来读取pickle数据流。
pickle的协议版本是自动检测的,因此不需要任何协议参数。超过pickle对象表示的字节将被忽略。
参数*file*必须有两个方法,一个read()方法接受一个整数参数,另一个readline()方法不需要参数。
这两个方法都应该返回字节。因此,*file*可以是打开用于读取的二进制文件对象,即io.BytesIO对象,或满足此接口的任何其他自定义对象。
可选关键字参数是*fix_imports*, *encoding*和*errors*,它们用于控制Python 2生成的pickle流的兼容性支持。
如果*fix_imports*为True, pickle将尝试将旧的Python 2名称映射到Python 3中使用的新名称。
*encoding*和*errors*告诉pickle如何解码Python 2 pickle的8位字符串实例;它们分别默认为'ASCII'和'strict'。
*encoding*可以是'bytes',将这些8位字符串实例读取为bytes对象。
data
1 memo=<attribute ‘memo’ of ‘_pickle.Unpickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Unpickler’>
2 persistent_load=<attribute ‘persistent_load’ of ‘_pickle.Unpickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Unpickler’>
method
3 find_class()
kind=method class=Unpickler objtype=method_descriptor
从指定的模块返回一个对象
。如果需要,将导入模块。
子类可以重写此方法(例如,限制任意类和函数的解pickle)。
当需要类或函数对象时调用此方法。传递的两个参数都是str对象。
4 load()
kind=method class=Unpickler objtype=method_descriptor
装上pickle。从构造函数中给定的打开文件对象读取pickle对象表示,并返回其中指定的重构对象层次结构。
内嵌函数或方法
39 pack
40 unpack
41 dump
42 dumps
43 load
44 loads
私有或局部
45 _extension_registry {}
46 _inverted_registry {}
47 _extension_cache {}
48 _compat_pickle <module ‘_compat_pickle’ from ‘…\lib\_compat_pickle.py’>
49 _Stop <class ‘pickle._Stop’>
50 _tuplesize2code [b’)‘, b’\x85’, b’\x86’, b’\x87’]
51 _Framer <class ‘pickle._Framer’>
52 _Unframer <class ‘pickle._Unframer’>
53 _getattribute <function _getattribute at 0x0000000002B3C048>
54 _Pickler <class ‘pickle._Pickler’>
55 _Unpickler <class ‘pickle._Unpickler’>
56 _dump <function _dump at 0x00000000038F2DC8>
57 _dumps <function _dumps at 0x00000000038FB678>
58 _load <function _load at 0x00000000038FB708>
59 _loads <function _loads at 0x00000000038FB798>
60 _test <function _test at 0x00000000038FB828>
剩余
61 loader <_frozen_importlib_external.SourceFileLoader object at 0x00000000038C1D08>
62 spec ModuleSpec(name=‘pickle’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x00000000038C1D08>, origin=‘…\lib\pickle.py’)
63 PyStringMap None
64 MARK b’(’
65 STOP b’.’
66 POP b’0’
67 POP_MARK b’1’
68 DUP b’2’
69 FLOAT b’F’
70 INT b’I’
71 BININT b’J’
72 BININT1 b’K’
73 LONG b’L’
74 BININT2 b’M’
75 NONE b’N’
76 PERSID b’P’
77 BINPERSID b’Q’
78 REDUCE b’R’
79 STRING b’S’
80 BINSTRING b’T’
81 SHORT_BINSTRING b’U’
82 UNICODE b’V’
83 BINUNICODE b’X’
84 APPEND b’a’
85 BUILD b’b’
86 GLOBAL b’c’
87 DICT b’d’
88 EMPTY_DICT b’}’
89 APPENDS b’e’
90 GET b’g’
91 BINGET b’h’
92 INST b’i’
93 LONG_BINGET b’j’
94 LIST b’l’
95 EMPTY_LIST b’]’
96 OBJ b’o’
97 PUT b’p’
98 BINPUT b’q’
99 LONG_BINPUT b’r’
100 SETITEM b’s’
101 TUPLE b’t’
102 EMPTY_TUPLE b’)’
103 SETITEMS b’u’
104 BINFLOAT b’G’
105 TRUE b’I01\n’
106 FALSE b’I00\n’
107 PROTO b’\x80’
108 NEWOBJ b’\x81’
109 EXT1 b’\x82’
110 EXT2 b’\x83’
111 EXT4 b’\x84’
112 TUPLE1 b’\x85’
113 TUPLE2 b’\x86’
114 TUPLE3 b’\x87’
115 NEWTRUE b’\x88’
116 NEWFALSE b’\x89’
117 LONG1 b’\x8a’
118 LONG4 b’\x8b’
119 BINBYTES b’B’
120 SHORT_BINBYTES b’C’
121 SHORT_BINUNICODE b’\x8c’
122 BINUNICODE8 b’\x8d’
123 BINBYTES8 b’\x8e’
124 EMPTY_SET b’\x8f’
125 ADDITEMS b’\x90’
126 FROZENSET b’\x91’
127 NEWOBJ_EX b’\x92’
128 STACK_GLOBAL b’\x93’
129 MEMOIZE b’\x94’
130 FRAME b’\x95’
【sys】
sys, fullname=sys, file=
【re】
re, fullname=re, file=re.py
【io】
io, fullname=io, file=io.py
【codecs】
codecs, fullname=codecs, file=codecs.py
【_compat_pickle】
_compat_pickle, fullname=_compat_pickle, file=_compat_pickle.py
统计
序号 | 类别 | 数量 |
---|---|---|
4 | str | 5 |
5 | tuple | 4 |
8 | dict | 5 |
13 | residual | 3 |
14 | system | 8 |
16 | all | 17 |
常量
str
1 excname ModuleNotFoundError
tuple
2 PYTHON2_EXCEPTIONS (‘ArithmeticError’, ‘AssertionError’, ‘AttributeError’, ‘BaseException’, ‘BufferError’, ‘BytesWarning’, 'DeprecationWarn…
3 MULTIPROCESSING_EXCEPTIONS (‘AuthenticationError’, ‘BufferTooShort’, ‘ProcessError’, ‘TimeoutError’)
4 PYTHON3_OSERROR_EXCEPTIONS (‘BrokenPipeError’, ‘ChildProcessError’, ‘ConnectionAbortedError’, ‘ConnectionError’, ‘ConnectionRefusedError’, 'Connect…
5 PYTHON3_IMPORTERROR_EXCEPTIONS (‘ModuleNotFoundError’,)
dict
6 IMPORT_MAPPING {‘builtin’: ‘builtins’, ‘copy_reg’: ‘copyreg’, ‘Queue’: ‘queue’, ‘SocketServer’: ‘socketserver’, ‘ConfigParser’: 'co…
7 NAME_MAPPING {(‘builtin’, ‘xrange’): (‘builtins’, ‘range’), (‘builtin’, ‘reduce’): (‘functools’, ‘reduce’), (‘builtin’, '…
8 REVERSE_IMPORT_MAPPING {‘builtins’: ‘builtin’, ‘copyreg’: ‘copy_reg’, ‘queue’: ‘Queue’, ‘socketserver’: ‘SocketServer’, ‘configparser’: 'Co…
9 REVERSE_NAME_MAPPING {(‘builtins’, ‘range’): (‘builtin’, ‘xrange’), (‘functools’, ‘reduce’): (‘builtin’, ‘reduce’), (‘sys’, ‘intern’)…
【_pickle】
_pickle, fullname=_pickle, file=
Python pickle模块的优化C实现。
统计
序号 | 类别 | 数量 |
---|---|---|
4 | str | 3 |
10 | class | 6 |
12 | builtin_function_or_method | 4 |
13 | residual | 1 |
14 | system | 5 |
16 | all | 14 |
常量
类
1 _pickle.Pickler
Pickler, _pickle.Pickler, module=_pickle
这需要一个二进制文件来写入pickle数据流。(参见前面)
data
1 bin=<member ‘bin’ of ‘_pickle.Pickler’ objects> kind:data type:member_descriptor class:<class ‘_pickle.Pickler’>
2 dispatch_table=<member ‘dispatch_table’ of ‘_pickle.Pickler’ objects> kind:data type:member_descriptor class:<class ‘_pickle.Pickler’>
3 fast=<member ‘fast’ of ‘_pickle.Pickler’ objects> kind:data type:member_descriptor class:<class ‘_pickle.Pickler’>
4 memo=<attribute ‘memo’ of ‘_pickle.Pickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Pickler’>
5 persistent_id=<attribute ‘persistent_id’ of ‘_pickle.Pickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Pickler’>
method
6 clear_memo()
kind=method class=Pickler objtype=method_descriptor
清除pickler的“备忘录”。(参见前面)
7 dump()
kind=method class=Pickler objtype=method_descriptor
将给定对象的pickle表示写入打开的文件。
2 _pickle.Unpickler
Unpickler, _pickle.Unpickler, module=_pickle
这需要一个二进制文件来读取pickle数据流。(参见前面)
data
1 memo=<attribute ‘memo’ of ‘_pickle.Unpickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Unpickler’>
2 persistent_load=<attribute ‘persistent_load’ of ‘_pickle.Unpickler’ objects> kind:data type:getset_descriptor class:<class ‘_pickle.Unpickler’>
method
3 find_class()
kind=method class=Unpickler objtype=method_descriptor
从指定的模块返回一个对象。(参见前面)
4 load()
kind=method class=Unpickler objtype=method_descriptor
装上泡菜。从构造函数中给定的打开文件对象读取pickle对象表示,并返回其中指定的重构对象层次结构。
3 _pickle.PickleError
PickleError, _pickle.PickleError, module=_pickle
4 _pickle.PicklingError
PicklingError, _pickle.PicklingError, module=_pickle
5 _pickle.UnpicklingError
UnpicklingError, _pickle.UnpicklingError, module=_pickle
内嵌函数或方法
6 dump
7 dumps
8 load
9 loads