售前咨询:400-100-2938
python中将函数动态绑定到对象,具体方法如下:
import typeclass Test(object):passt=Test()def eat(self): print(“eat”)t.eat = types.MethodType(eat,p1)
import type
class Test(object):
pass
t=Test()
def eat(self):
print(“eat”)
t.eat = types.MethodType(eat,p1)
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:python如何给对象赋值