擅长:python、mysql、java
<p>以下应该可以实现所需的功能</p>
<pre><code>from collections import Counter
output = Counter()
with open("input.txt") as file:
for line in file.read().split('\n'):
if line:
key, value = line.split()
output[key] += int(value)
with open("output.txt", 'w+') as file:
for key, value in output.items():
file.write("{key} {value}\n".format(key=key, value=value))
</code></pre>