擅长:python、mysql、java
<p>您可以使用<a href="https://docs.python.org/2/library/collections.html#collections.Counter" rel="nofollow">collections.Counter</a>dict:</p>
<pre><code>from collections import Counter
with open('yourfile') as f:
count = Counter (line.split()[0] for line in f)
</code></pre>
<p>很抱歉有任何错误,这是从手机写的:)</p>