python内置函数——callable

1、关于callable详细解说:

Signature: callable(obj, /)
Docstring:
Return whether the object is callable (i.e., some kind of function).

Note that classes are callable, as are instances of classes with a
__call__() method.
Type:      builtin_function_or_method

2、具体用法(代码示例):

>>> import math
>>> x = 1
>>> y = math.sqrt
>>> callable(x)
False
>>> callable(y)
True

作者总结了更全面的解释https://www.cnblogs.com/sesshoumaru/p/5983979.html

猜你喜欢

转载自blog.csdn.net/Bug_fuck/article/details/85690464