class Cell:
_a = 'a'
@property
def state(self):
return self._a
@state.setter
def state(self,value):
self._a = value
if __name__ == '__main__':
c = Cell()
c.stare = 'b' #设置
print(c.state) #读取
class Cell:
_a = 'a'
@property
def state(self):
return self._a
@state.setter
def state(self,value):
self._a = value
if __name__ == '__main__':
c = Cell()
c.stare = 'b' #设置
print(c.state) #读取
本文标题:@property关键字
本文链接:https://www.haomeiwen.com/subject/rqhzqctx.html
网友评论