擅长:python、mysql、java
<pre><code>import collections
result=collections.defaultdict(list)
with open('data','r') as f:
for line in f:
line=line.split()
key=line[0]
value=float(line[1])
result[key].append(value)
for key,values in result.iteritems():
print(key,sum(values))
</code></pre>
<p>产量:</p>
^{pr2}$
<p>这和你想要的格式接近吗?在</p>