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('不知道是什么')

    if type(arg)== MethodType:
        print('arg是一个方法')
    elif type(arg) == FunctionType:
        print('arg是一个函数')
    else:
        print('不知道是什么')

 

相关文章:

  • 2021-11-20
  • 2021-07-26
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-02-06
  • 2021-12-30
相关资源
相似解决方案