运行下列四个选项的程序,不会抛出异常的是()
运行下列四个选项的程序,不会抛出异常的是()
class Rect:
def __init__(self,width,height):
self.width = width
self.height = height
@property
def area(self):
return self.height* self.width
rect = Rect(10,20)
rect.area()
a = 0
def fun():
a += 1
print(a)
fun()
class Animal:
def __init__(self,color="白色"):
Animal.color = color
def get_color(self):
print("Animal的颜色为",Animal.color)class Cat(Animal):def __init__(self):
pass
cat = Cat()
cat.get_color()
class Cat:
def __init__(self,color="白色"):
self.__color = color
cat = Cat("绿色")
print(cat._Cat__color)