class D():
def __init__(self, init_age):
print('我年龄是:', init_age)
self.age = init_age
def __call__(self, added_age):
res = self.forward(added_age)
return res
def forward(self, input_):
print('forward 函数被调用了')
return input_ + self.age
print('对象初始化。。。。')
a = D(10)
input_param = a(2)
print("我现在的年龄是:", input_param)
init call forward
最新推荐文章于 2024-07-04 16:04:39 发布