__call__方法和可调用对象
定义了call方法的对象,称为可调用对象,即该对象可以像函数一样调用
a = 30
b = 50
c = a+b ===>c = a.__add__(b)
obj() ====>__call__
1 class SalaryAcount: 2 def __call__(self, salary): 3 yearSalary = salary*12 4 MouthSalary = salary 5 daySalary = salary//22.7 6 hourSalary = daySalary//8 7 8 return dict(yearSalary=yearSalary,MouthSalary=salary,daySalary=daySalary,hourSalary=hourSalary) 9 10 s = SalaryAcount() 11 print(s(30000))