还是没弄明白这个函数要怎么用
class Person(object): def __init__(self, name, gender): self.name = name self.gender = gender def __call__(self, friend): print('My name is {}...'.format(self.name)) print('My friend is {}...'.format(friend)) >>> p = Person('Bob', 'Male')
>>> p('Alice') # ==> 用函数的方式调用Person类的实例p My name is Bob... My friend is Alice...