检查arg是方法还是函数?

from types import MethodType,FunctionType
def check(arg):
    """
    检查arg是方法还是函数?
    :param arg:
    :return:
    """
    if isinstance(arg,MethodType):
        print('arg是一个方法')
    elif isinstance(arg,FunctionType):
        print('arg是一个函数')
    else:
        print('不知道是什么')

猜你喜欢

转载自www.cnblogs.com/apollo1616/p/9776051.html