擅长:python、mysql、java
<p>我会使用<a href="http://docs.python.org/2/library/collections.html#counter-objects" rel="nofollow">^{<cd1>}</a>,因为这就是它的用途:</p>
<pre><code>from random import randint
from collections import Counter
counts = Counter(randint(1, 6) + randint(1, 6) for i in range(100000))
total = sum(counts.values())
number_of_tens = counts[10]
</code></pre>