擅长:python、mysql、java
<p>当您定义:</p>
<pre><code>class StrMixin(object):
...
</code></pre>
<p>编译器知道在类的MRO中,<code>StrMixin</code>在<code>object</code>之前。在</p>
<p>当您这样做时:</p>
^{pr2}$
<p>您已经告诉编译器在MRO中,<code>object</code>在<code>StrMixin</code>之前。但是<code>object</code>也必须在<code>StrMixin</code>之后,所以它必须在MRO中出现两次,这是不允许的。在</p>
<p>如果你说:</p>
<pre><code>class C(StrMixin, object):
pass
</code></pre>
<p>那么MRO就是<code>C</code>,<code>StrMixin</code>,<code>object</code>,它满足两个类所施加的顺序。不存在重复,因为尽管<code>object</code>被引用了两次,但定义之间没有冲突。在</p>