类和函数的区别
类外面: ---- 函数
类里面
  取决调用者
  类.func(xx) ---- 函数
  对象.func() ----方法
可以使用 MethodType, FunctionType来判断:
from types import MethodType, FunctionType class A: def func(self): return 123 print(isinstance(A.func, MethodType)) # False print(isinstance(A.func, FunctionType)) # True 类调用,是函数 a = A() print(isinstance(a.func, MethodType)) # True 对象调用, 是方法 print(isinstance(a.func, FunctionType)) # False 复制代码
    接近财富自由第不知道多少天
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号