2024-04-18 20:50:49 发布
网友
通过实现__call__方法,可以使对象可调用:
__call__
class FunctionLike(object): def __call__(self, a): print("I got called with {!r}!".format(a)) fn = FunctionLike() fn(10) # --> I got called with 10!
通过实现
__call__
方法,可以使对象可调用:相关问题 更多 >
编程相关推荐