函數,方法 別再傻傻分不清
from types import MethodType(方法),FunctionType(函數) def func(): pass print(isinstance(func,FunctionType)) # True class A(): def aaa(self): pass print(isinstance(aaa,FunctionType)) # True a=A() print(isinstance(a.aaa,MethodType)) # True要有實例化出來的對象才可以,如果只是用類名去調用的話還是function,只有用實例化出來的對象去調用才可以得到method 我們的函數只有跟我們的實例化出來的對象有綁定關系才能稱之為方法,否則都是函數,即便它是寫到類里面的方法,沒有跟我們的類實例化出來的對象進行綁定,它依然是函數,而不是類里面的方法.