from dis import disassemble
def main1():
a=12
print(a)
disassemble(main1)
上面的代码给出了错误AttributeError: 'function' object has no attribute 'co_code'
,有人可以帮忙吗?
答案 0 :(得分:0)
阅读https://docs.python.org/2/library/dis.html#dis.disassemble
你需要写表达式正确
disassemble(main1.__code__)或
from dis import dis def main1(): a=12 print(a) dis(main1)