一般来说,函数与方法对我们而言就是在类里面的是方法,在外面的是函数。
但具体的来说是不够准确。

而判断函数与方法可以引用MethodType,FunctionType。
1 from types import MethodType,FunctionType 2 def check(arg): 3 """ 4 检查arg是方法还是函数? 5 :param arg: 6 :return: 7 """ 8 if isinstance(arg,MethodType): 9 print('arg是一个方法') 10 elif isinstance(arg,FunctionType): 11 print('arg是一个函数') 12 else: 13 print('不知道是什么')