1、下面这段代码的输出结果将是什么?请解释。
class Parent(object): # 定义一个父类
x = 1
class Child1(Parent): # 定义一个子类1
pass
class Child2(Parent): # 定义一个子类2
pass
print(Parent.x, Child1.x, Child2.x)
# 打印结果为:1 1 1
# 类child1、child2都继承了父类Parent,子类中没有x,就去父类中找到x
Child1.x = 2
print(Parent.x, Child1.x, Child2.x)
# Child1调用了父类的X并给其赋值2
# 打印结果为:1 2 1
Parent.x = 3
print(Parent.x, Child1.x, Child2.x)
# 父类的x值变为3,Child1调用父类x并给其赋值2,Child2调用父类的x
# 打印结果为:3 2 31、下面这段代码的输出结果将是什么?请解释。
class Parent(object):