LoginSignup
17
11

More than 5 years have passed since last update.

defaultdictを使って,ネストされた辞書を作る

Last updated at Posted at 2012-11-27

たとえば

import collections
d = collections.defaultdict(lambda:collections.defaultdict(float))

のようにすれば

d['poko']['hoge'] += 1.0

みたいなカウントアップがsetdefaultを書かずに書ける

17
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
11