擅长:python、mysql、java
<p>你的代码有两个问题。在python 2中:</p>
<ol>
<li><code>super()</code>有两个参数:类名和实例</li>
<li>为了使用<code>super()</code>,基类必须从<code>object</code>继承</li>
</ol>
<p>所以你的代码变成:</p>
<pre><code>import scipy.io
class Proband(object):
def __init__(self,idn,artefakte):
self.__idn = idn
self.artefakte = artefakte
def getData(self):
path = 'C:\matlab\EKGnurbild_von Proband'+ str(self.idn)
return scipy.io.loadmat(path)
def __eq__(self,neueProband):
return self.idn == neueProband.idn and self.artefakte == neueProband.artefakte
class Gesunder(Proband):
def __init__(self,idn,artefakte,sportler):
super(Gesunder, self).__init__(idn,artefakte)
self.__sportler = sportler
hans = Gesunder(2,3,3)
</code></pre>
<p>注意对<code>super(Gesunder, self).__init__</code>的调用没有<code>self</code>作为第一个参数。你知道吗</p>