标签:length aic static war Owner ini *args 描述 __init__
通过描述符和类装饰器,自定义staicmethod(静态方法)
class StaticMethod: def __init__(self,func): self.func = func def __get__(self, instance, owner): def deco(*args,**kwargs): return self.func(*args,**kwargs) return deco class Room: @staticmethod def area(width,length,higt): return width * length * higt @StaticMethod def area1(width,length,higt): return width * length * higt print(Room.area(10,20,1)) print(Room.area1(10,20,1)) r = Room() print(r.area(10,20,2)) print(r.area1(10,20,2))
通过描述符和类装饰器,自定义staicmethod(静态方法)
标签:length aic static war Owner ini *args 描述 __init__
原文地址:https://www.cnblogs.com/xieys-1993/p/11596066.html