class A(object): x = 1 class B(A): pass class C(A): pass # 通过父类修改类属性,子类继承的类属性也改变 A.x = 3 print(A.x, B.x, C.x) # 通过子类修改继承自父类的类属性,只会改变该子类继承的类属性 B.x = 2 print(A.x, B.x, C.x) # 子类先修改继承的类属性,父类再修改类属性,将不会再对已经修改过的子类类属性做出改变 B.x = 4 A.x = 1 print(A.x, B.x, C.x…