标签:ret turn asd fas dfa def 使用 init fda
class People:
def __init__(self, name):
# print(‘init‘)
self.__name = name
@property
def name(self):
print(‘get‘)
return self.__name
@name.setter
def name(self, val):
print(‘set‘)
if not isinstance(val, str):
print(‘名字必须是字符串类型‘)
return
self.__name = val
@name.deleter
def name(self):
print(‘delet‘)
p = People(‘hhhh‘)
p.name # 查询
p.name = ‘safdfasfdasd‘ # 赋值
del p.name # 删除
标签:ret turn asd fas dfa def 使用 init fda
原文地址:https://www.cnblogs.com/jt925/p/10360389.html