python property使用
发布时间:2023-02-05 11:11:03 309 相关标签:
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
文章来源: https://blog.51cto.com/haoyonghui/6019237
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报