python
文章平均质量分 56
dai__liang
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python装饰器(二)
内置的装饰器property先看一个例子:class Student(): def __init__(self, age): self.age = age a = Student(18)a.age = 20这里age属性可以被直接更改,如果我们需要实现age私有化,可以使用如下:class Student(): def __init__(self, age): self.__age = age def getage(self): print(self.__age原创 2021-03-05 16:20:15 · 187 阅读 · 0 评论 -
Python装饰器(一)
为什么需要装饰器先看两个例子def one_hello(): print ("hello!") def two_hello(): print ("hello!") if __name__ == '__main__': one_hello() two_hello()如果我们要调试这两个函数,有时候会要求调用每个方法前都要记录进入函数的名称,可以最原始的方法如下:def one_hello(): print "[DEBUG]: enter one_h原创 2021-03-05 15:23:33 · 172 阅读 · 0 评论
分享