對象通過提供__call__(slef, [,*args [,**kwargs]])方法可以模擬函數(shù)的行為,如果一個對象x提供了該方法,就可以像函數(shù)一樣使用它,也就是說x(arg1, arg2...) 等同于調(diào)用x.__call__(self, arg1, arg2)。模擬函數(shù)的對象可以用于創(chuàng)建仿函數(shù)(functor) 或代理(proxy) 1 2 3 4 5 6 7 8 classDistance...
www.dbjr.com.cn/article/672...htm 2025-5-25