例如:
class Rectangle: def __init__(self, width, height): self.width = width self.height = height rect = Rectangle(7, 8) print(rect.color)
结果:
>>> AttributeError: 'Rectangle' object has no attribute 'color' >>>
0