擅长:python、mysql、java
<p>您的<code>mixture</code>方法没有生成新实例。它只返回<code>self.r</code>值(多次使用<code>return</code>不做任何事情;第一个结束方法)。我看不出你有什么办法;示例代码中没有<code>str</code>。大概,您希望<code>mixture</code>有这样的功能:</p>
<pre><code>def mixture(self, f):
# For subclassing friendliness, you might construct via:
# type(self)(...) instead of Color(...)
return Color((self.r + f.r) // 2, (self.g + f.g) // 2, (self.b + f.b) // 2)
</code></pre>