方法1:


callable(fn) //返回True或False

方法2:


hasattr(fn, '__call__') //返回True或False

方法3:需要引入types模块


import types
isinstance(f, types.FunctionType)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2021-08-16
  • 2021-11-09
  • 2021-10-30
猜你喜欢
  • 2022-12-23
  • 2021-11-15
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
相关资源
相似解决方案