@ 修饰器

比如 f1() 为需要修饰的函数, xiushi()为修饰函数

@xiushi  等价于  f1 = xiushi(f1)

作用在于不改变 f1() 函数的情况下,加入一点修饰函数中的东西

  

类中的装饰器

 

  @staticmethod静态方法不能调用类属性和方法

  @property  不用写()直接调用函数

  @classmethod类方法 可调用类的属性

猜你喜欢

转载自www.cnblogs.com/cxhzy/p/9853515.html
今日推荐