AttributeError:'function'对象没有属性'co_code'

时间:2016-03-19 09:44:47

标签: python

from dis import disassemble


def main1():
    a=12
    print(a)


disassemble(main1)

上面的代码给出了错误AttributeError: 'function' object has no attribute 'co_code',有人可以帮忙吗?

1 个答案:

答案 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)