擅长:python、mysql、java
<p>在python中类是对象,即类是“与其他类一样的东西”
在你的例子中</p>
<pre><code>class Foo():
pass
x = Foo()
type(x) # Foo, x is a Foo
type(Foo) # type, Foo is a type
</code></pre>
<p>你定义的类不仅仅是一段代码。它是一个占用内存空间的物体。在</p>
^{pr2}$
<p>是有效的操作。在</p>
<pre><code>>>> type(type(Foo))
<type 'type'>
</code></pre>
<p>类型是一种特殊的类(<a href="https://stackoverflow.com/a/6581949/3857234">metaclass</a>)
它的对象是可以创建对象的类</p>