方法一:code

    1. def func():
    2. pass
    3. hasattr(func,'__code__')

    方法二:type(func)看是否为Function

    1. from types import FunctionType
    2. def func():
    3. pass
    4. if type(func) == FunctionType:
    5. pass