下列代码输出结果是10。( )class MyClass(): class_attribute = 10MyClass.class_attribute = 20 print(MyClass.class_attribute)
【喵呜刷题小喵解析】:在Python中,类变量(也称为类属性)是在类级别定义的,而不是在实例级别。在给出的代码中,`class_attribute`被定义在`MyClass`类中,其初始值为10。然后,尝试将`MyClass.class_attribute`设置为20,这不会改变其初始值。最后,打印`MyClass.class_attribute`将输出其初始值,即10,而不是20。因此,题目中的判断是正确的,答案是B。