标签:*args @class color turn 原理 ini nat span get
classmethod
class Classmethod: def __init__(self,func): self.func=func def __get__(self, instance, owner): def test(*args,**kwargs): return self.func(owner,*args,**kwargs) return test class Cq: red=1 @Classmethod #test=Classmethod(test) def test(cls): return cls.red print(Cq.test())
staticmethod
class Staticmethod: def __init__(self,func): self.func=func def __get__(self, instance, owner): def nat(*args,**kwargs): return self.func(*args,**kwargs) return nat class Coo: def __init__(self,name,age): self.name=name self.age=age @Staticmethod #test=Staticmethod(test) def test(name2,age1): s=2 return s c=Coo("ljh",18) print(c.test("ljh",19))
classmethod 和 staticmethod 工作原理
标签:*args @class color turn 原理 ini nat span get
原文地址:https://www.cnblogs.com/rxybk/p/13284852.html