From 4d74d5ea4469dc09338233aea6394cc9cd09f383 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 15 Sep 2025 16:08:20 +0800 Subject: [PATCH] =?UTF-8?q?09-15-=E5=91=A8=E4=B8=80=5F16-08-20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02.面向对象/05.类的成员.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/02.面向对象/05.类的成员.md b/02.面向对象/05.类的成员.md index ec32af5..463436b 100644 --- a/02.面向对象/05.类的成员.md +++ b/02.面向对象/05.类的成员.md @@ -473,4 +473,15 @@ print(isinstance([1,2,3], Iterable)) # True print(issubclass(list,Iterable)) # True # 由上面的例子可得,这些可迭代的数据类型,list str tuple dict等 都是 Iterable的子类。 -``` \ No newline at end of file +``` + +这种继承关系形成了Python对象模型的闭环:object是所有类的基类,type是所有类型的基类,而type本身又是object的子类。 + +```python +print(isinstance(object, type)) +print(issubclass(type, object)) + +# object是type的实例(因为type创建了object类) +# type是object的子类(因为所有类都继承自object,包括type本身)。 +``` +