阅读量:117

python中将函数动态绑定到对象,具体方法如下:
import type
class Test(object):
pass
t=Test()
def eat(self):
print(“eat”)
t.eat = types.MethodType(eat,p1)

python中将函数动态绑定到对象,具体方法如下:
import type
class Test(object):
pass
t=Test()
def eat(self):
print(“eat”)
t.eat = types.MethodType(eat,p1)