以下代码的输出结果是什么? 产生此结果的原因是什么? class An...

发布于 2022-03-03 16:54:16

以下代码的输出结果是什么? 产生此结果的原因是什么?
class Animal(object): 
    weight = 9
class Dog(Animal): 
    pass
class Cat(Animal): 
    pass
 
print Animal.weight, Dog.weight, Cat.weight
Cat.weight = 8
print Animal.weight, Dog.weight, Cat.weight
Animal.weight = 7
print Animal.weight, Dog.weight, Cat.weight

关注者
0
被浏览
22
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看