__call__ 方法 __call__ 是当对象被调用时会调用的方法,允许一个对象(类的实例等)像函数一样被调用,也可以传入参数. 1 class Foo(): 2 def __init__(self, x, y): 3 self.x = x 4 self.y = y 5 6 def __call__(self, m, n): 7 print('x is %s, y is %s, m is %s, n is %s' % (self.x, self.y, m, n)) 8 9 Foo(1, 2)…