擅长:python、mysql、java
<p>你可以用<a href="https://docs.python.org/3.1/library/collections.html#collections.Counter" rel="nofollow noreferrer">^{<cd1>}:</a></p>
<pre><code>from collections import Counter
words = []
for line in open('data.txt'):
# Your logic here
words.append(line.split()[1])
words_dict = Counter(words)
for key, value in words_dict.items():
print(key, value)
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>303574 1
55596 3
303630 1
303567 1
303595 1
303616 1
240840 3
303588 1
55590 1
303623 1
303602 1
303581 1
55608 3
303609 1
</code></pre>