擅长:python、mysql、java
<p><code>array.array</code>类将负责<code>float</code>部分:</p>
<pre><code>class AverageList(array.array):
def __new__(cls, *args, **kw):
return array.array.__new__(cls, 'd')
def __init__(self, values=()):
self.extend(values)
def __repr__(self):
if not len(self): return 'Empty'
return repr(math.fsum(self)/len(self))
</code></pre>
<p>还有一些测试:</p>
^{pr2}$