python 判定变量是函数
方法1:
callable
(fn)
/
/
返回
True
或
False
|
方法2:
hasattr
(fn,
'__call__'
)
/
/
返回
True
或
False
|
方法3:需要引入types模块
import
types
isinstance
(f, types.FunctionType)
|