class Student:
def __init__(self,name,age):
self.name=name
self.__age=age #####年龄不希望在类的外部被使用,所以加__
def show(self):
print(self.name,self.__age)
stu=Student('张三',20)
stu.show()
#在类的外部使用name ,age
print(stu.name)
# print(stu.__age) ###报错
# print(dir(stu)) ####获取_Student__age
print(stu._Student__age)#####可以输出age