装饰器

普通装饰器

修饰符号:@

本质是闭包

https://www.runoob.com/w3cnote/python-func-decorators.html

多层装饰器

顺序为从下至上

带参装饰器

内置装饰器

@property

方法转换为相同名称的只读属性

1
2
3
4
5
6
7
8
9
10
class dataset(object):
@property
def fun1(self):
return 13
def fun2(self):
return 13

a=dataset()
print(a.fun1)
print(a.fun2())

@staticmethod

@classmthod

https://zhuanlan.zhihu.com/p/35643573

Author

Lavine Hu

Posted on

2022-09-12

Updated on

2024-04-13

Licensed under

# Related Post
  1.logging
  2.python内存管理
  3.路径
  4.pandas
  5.
  6.metaclass
  7.unittest
  8.list
Comments

:D 一言句子获取中...