對象後面加括號時,觸發執行。python
注:code
列子---> 和 __init__ 結合着看對象
class Foo: # 這邊 建立實例時候回觸發 __init__ def __init__(self): print('__init__觸發了') def __call__(self, *args, **kwargs): print('__call__觸發了') obj = Foo() # 執行 __init__ # 輸出結果 # __init__觸發了 obj() # 執行 __call__ # 輸出結果 # __call__