定义了call 函数之后,类可以像函数一样调用(实际调用的是call函数)
class A(object): def __init__(self, name, age): self.name = name self.age = age def __call__(self): print('my name is %s' % self.name) print('my age is %s' % self.age) if __name__ == '__main__': a = A('jack', 26)()