python中如何动态给对象绑定函数
lewis
2019-03-16
22次阅读
python中将函数动态绑定到对象,具体方法如下:
import type
class Test(object):
pass
t=Test()
def eat(self):
print(“eat”)
t.eat = types.MethodType(eat,p1)

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。