擅长:python、mysql、java
<p>您得到的堆栈错误是:</p>
<pre><code>Traceback (most recent call last):
File "C:/Users/cd00119621/PycharmProjects/ideas/stackoverflow.py", line 16, in <module>
print(l.totalPayments())
File "C:/Users/cd00119621/PycharmProjects/ideas/stackoverflow.py", line 13, in totalPayments
return (self.monthlyPayment(self) * self._term)
TypeError: monthlyPayment() missing 2 required positional arguments: 'rate' and 'term'
</code></pre>
<p>这里的线索是<code>monthlyPayment()</code>方法给出了缺少2个参数的错误。此方法需要传递3个参数(不包括self),第4个参数是可选的。在</p>
<p><code>def monthlyPayment(cls,face,rate,term,period=None):</code></p>
<p>但是当你从你的<code>totalPayments</code>方法调用它时,你只传递了一个参数self。在</p>
<p><code>return (self.monthlyPayment(self) * self._term)</code></p>
<p>您不需要传递self,它将自动传递,因此您需要传递其他3个预期的参数<code>face,rate,term</code></p>