class people:
#定义基本属性
name = ''
age = 0
#定义私有属性,私有属性在类外部无法直接进行访问
__weight = 0
# 定义构造方法
def __init__(self,n,a,w):
self.name = n
self.age = a
self.__weight = w
def speak(self):
print("%s 说: 我 %d 岁。" %(self.name,self.age))
def out_weight(self):
print('my weight is ',self.__weight)

return self.__weight
p = people('lg',30,70)
p.speak()

print(p.name,p.age)

p.out_weight()
print(p.__weight)
lg 说: 我 30 岁。
lg 30
my weight is 70
AttributeError: 'people' object has no attribute '__weight'