使用到装饰器property和setter
在这里插入代码片
```class A:
@property
def s_password(self):
raise Exception("Error Action: Password can't be access")
@s_password.setter
def s_password(self, value):
self._s_password = generate_password_hash(value)
def check_password(self, password):
return check_password_hash(self._s_password, password)
a = A()
a.s_password = "1"
print(a.check_password("1"))