python小白请教pickle.dump生成的文件格式内容。
2个回答
展开全部
import pickletools
pickletools.dis(open('pickle.dump','rb'))
pickletools.dis(open('pickle.dump','rb'))
追问
好像不行哦。你能否直接告诉我这些字符的意思呢?谢谢
追答
import pickle,pickletools
def func():
return 0
x={'a':1,'b':'asdf','c':func}
with open('x.dump','wb') as f:
pickle.dump(x,f)
with open('x.dump','rb') as f:
pickletools.dis(f)
#####
output
#####
0: ( MARK
1: d DICT (MARK at 0)
2: p PUT 0
5: S STRING 'a'
10: p PUT 1
13: I INT 1
16: s SETITEM
17: S STRING 'c'
22: p PUT 2
25: c GLOBAL '__main__ func'
40: p PUT 3
43: s SETITEM
44: S STRING 'b'
49: p PUT 4
52: S STRING 'asdf'
60: p PUT 5
63: s SETITEM
64: . STOP
highest protocol among opcodes = 0
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询