Python3-私有属性
1 class Person:
2 __age = 20
3
4 @classmethod
5 def update_age(cls):
6 cls.__age = 18
7
8 @classmethod
9 def show_age(cls):
10 print("修改后的年龄是:",cls.__age)
11
12 Person.update_age()
13 Person.show_age() # 改后的年龄是: 18