在 Python 中,你可以使用 `bases` 属性来查看一个类的所有直接父类。`bases` 属性返回一个包含所有直接父类的元组。这里是如何使用它的示例:
class Parent:passclass Child(Parent):pass查看 Child 类的直接父类print(Child.bases) 输出: (,)
如果你想要查看一个对象的父类,你可以使用 `.__class__` 属性,然后访问该类的 `__bases__` 属性:

class Parent:passclass Child(Parent):pass创建 Child 类的实例child_instance = Child()查看实例的父类print(child_instance.__class__.__bases__) 输出: (,)
请注意,`__bases__` 属性返回的是包含所有直接父类的元组,而 `bases` 属性是类对象的一个属性,直接反映了类的继承关系。
