特殊方法 call
"""
特殊方法 __call__
__call__ 方法可以像函数一样调用
"""
class data(object):
def __call__(self):
return "这是 __call__ 方法"
data1 = data()
print(data1())
print()
print()
class numerical_value(object):
def __call__(self, args, kwargs):
y = 5464
return ((args + args * kwargs) + (kwargs + kwargs * args)) * 6 + y
def p(self,x,y):
return x + y
x = numerical_value()
print(x(45.5,45.9))
print(x.p(y = 4, x = 34))