![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
与子成说QAQ
这个作者很懒,什么都没留下…
展开
-
【Python】@property的简单介绍
@property 使Python的一种装饰器,用来修饰方法。 我们可以使用@property装饰器来创建只读属性,@property装饰器会将方法转换为相同名称的只读属性,可以与所定义的属性配合使用,这样可以防止属性被修改。 class DataSet(object): @property def method_with_property(self): ##含有@property return 15 def method_without_property(self): ##不含@p转载 2020-07-23 20:32:11 · 172 阅读 · 0 评论 -
【Python】类中 _ 、__ 和 __xx__
文章参考并转自https://blog.csdn.net/sishi22/article/details/88028420 _xx 单下划线开头 Python中不存在真正的私有方法。为了实现类似于c++中私有方法,可以在类的方法或属性前加一个“_”单下划线,意味着该方法或属性不应该去调用,它并不属于API。 class Test(): def __init__(self): pass def _one_underline(self): # 定义私有方法,都只能被类中的函数调转载 2020-07-23 20:20:09 · 315 阅读 · 0 评论