凉夜lrs

关注

python property使用

凉夜lrs

关注

阅读 83

2023-01-18

class Goods():
def __init__(self):
self._price = ""

@property
def price(self):
return self._price

@price.setter
def price(self, value):
self._price = value

@price.deleter
def price(self):
del self._price

g = Goods()
a = g.price
print(a)

g.price = 123
b = g.price
print(b)

del g.price

相关推荐

ITWYY

Python中@Property属性使用

ITWYY 96 0 0

王栩的文字

python @property,@staticmethod,@classmethod 使用例子

王栩的文字 58 0 0

悬灸人雪洋

Python的@property

悬灸人雪洋 67 0 0

圣杰

python 类property装饰器, setter,getter使用

圣杰 56 0 0

夕阳孤草

python类中property的使用 - python 计算函数时间

夕阳孤草 61 0 0

吴wuwu

Python装饰器:@property

吴wuwu 181 0 0

哈哈镜6567

Python装饰器------@property

哈哈镜6567 165 0 0

boomwu

Python(十、property属性)

boomwu 99 0 0

以沫的窝

python-@property 属性

以沫的窝 62 0 0

小a草

ant的property使用

小a草 64 0 0

精彩评论(0)

0 0 举报