小编Lon*_*ian的帖子

当类中嵌入的函数是类的"方法"时?

执行此操作时......

class A:
    def b(self, a):
        print a
    print dir(b)
print dir(A.b)
Run Code Online (Sandbox Code Playgroud)

它给出了结果:

['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__',
 '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__',
 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'func_closure',
 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']

['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__get__',
 '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__',
 '__repr__', '__setattr__', '__str__', 'im_class', 'im_func', 'im_self']
Run Code Online (Sandbox Code Playgroud)

为什么这个不同?

python

4
推荐指数
1
解决办法
236
查看次数

标签 统计

python ×1