擅长:python、mysql、java
<p>您需要显式初始化超类。编辑<code>__init__</code>的<code>bb</code>方法,使其如下所示:</p>
<pre><code>class bb(aa):
def __init__(self):
super(bb, self).__init__() # Call the __init__ method of the superclass.
self.weight = 13
</code></pre>
<p>然后它应该工作:</p>
<pre><code>print AA.height # 12
print BB.height # 12
</code></pre>
<hr/>
<p>关于使用超类的文档,请参阅文档中的<a href="https://docs.python.org/2/library/functions.html#super" rel="nofollow">^{<cd3>}</a>函数。你知道吗</p>