python-「解読」プライベート属性
#coding:utf-8
class A:
def __init__(self, name, age, pwd):
self.__name = name
self.__age = age
self.__pwd = pwd
def decrypt(self, passwd):
if passwd == self.__pwd:
print({"name":self.__name, "age":self.__age})
else:
print("No access to the object's data")
if __name__ == '__main__':
a = A("toby", 25, "1qaz@WSX") # , ,
#a.decrypt("123!QA") # ,
#a.decrypt("1qaz@WSX") # ,
# ? ?
print(a._A__age)
print(a._A__name)
print(a._A__pwd)
"""
:
0、 , , “ ”
1、 , :_
2、 : _A
3、 , ,
3、 , “ ”
"""