__code__拿到代码信息

来源:互联网 发布:淘宝主营类目多久更新 编辑:程序博客网 时间:2024/04/28 20:13
__code__ 示例:>>> def func(arg1,arg2):...     return arg1*arg2... >>> print dir(func.__code__)['__class__', '__cmp__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize', 'co_varnames']>>> print func.__code__.co_varnames('arg1', 'arg2')>>> print func.__code__.co_namefunc

0 0
原创粉丝点击