擅长:python、mysql、java
<p><a href="https://docs.python.org/2/library/collections.html#collections.defaultdict" rel="nofollow">collections.defaultdict</a>可以帮助构建一个pythonic</em>代码:</p>
<pre><code>count = collections.defaultdict(int) # => default value is 0
...
count[event] += 1 # will end to 1 on first hit and will increment later
</code></pre>