Python之面向对象学习1

def foo(x):
print(x)

print(foo.__dict__)
print(foo.__call__)
print(dir(foo))

class A:
def __call__(self, *args, **kwargs):
print(5)

A()() #调用实例的call方法
a= A()
a(3,4)

猜你喜欢

转载自www.cnblogs.com/ergePython/p/11455591.html