python -- 模块pickletools测试

2019-04-15 19:18发布

#! /usr/bin/env python3 # filename : modules.py # author : zoujiameng@aliyun.com.cn import pickletools def protocol_version(file_object): maxproto = -1 count = 0 for opcode, arg, pos in pickletools.genops(file_object): maxproto = max(maxproto, opcode.proto) count += 1 print("count = " + str(count)) return maxproto r''' def opcode_print(file_object): for opcode, arg, pos in pickletools.genops(file_object): print(opcode.name, opcode.code, opcode.arg, opcode.stack_before, opcode.stack_after, opcode.proto, opcode.doc) print(arg) print(pos) print("--------------")''' with open('x.pickle', 'rb') as f: v=protocol_version(f) print(v) vv = opcode_print(f)

G M T 文本转语音功能仅限200个字符 选项 : 历史 : 反馈 : Donate 关闭