python中动态绑定一个函数到对象
import type
class Test(object):
pass
t=Test()
def eat(self): #作为导入方法这个self不能忘了
print(“eat”)
t.eat = types.MethodType(eat,p1)
import type
class Test(object):
pass
t=Test()
def eat(self): #作为导入方法这个self不能忘了
print(“eat”)
t.eat = types.MethodType(eat,p1)