擅长:python、mysql、java
<p>您可以使用<code>Counter</code>,这就是它们的用途</p>
<pre><code>from collections import Counter
print Counter(Counter(test).values())
</code></pre>
<p>例如</p>
<pre><code>test = ["the", "sun", "rises", "in", "the", "sun"]
from collections import Counter
print Counter(test)
print Counter(Counter(test).values())
</code></pre>
<p><strong>输出</strong></p>
<pre><code>Counter({'sun': 2, 'the': 2, 'rises': 1, 'in': 1})
Counter({1: 2, 2: 2})
</code></pre>