class Cat: def __init__(self, name): self.name = name def meow(self): print("Meow!")cat = Cat("咪咪")print(type(cat)) # <class '__main__.Cat'>print(isinstance(cat, Cat)) # Trueprint(dir(cat)) # 包含 'name', 'meow', 以及其他默认属性print(hasattr(cat, 'name')) # Trueprint(getattr(cat, 'age', 2)) # 2(默认值)setattr(cat, 'color', 'white')print(cat.color) # white