2016-10-13 21 views

答えて

2

使用collections.defaultdictcollections.Counterで。

from collections import defaultdict, Counter 

d = defaultdict(Counter) 
d['year']['month'] += 1 
+0

いいえ、次の場合はうまくいきません: – buslik

+0

d [年] [月] [日] + = 1 – buslik

+0

@buslik 'd ['year'] ['month'] + = 1 'd ['year'] ['month']'の値を 'int'オブジェクトに設定します。 –

0

最後に、タプル付きのカウンターをキーとして使用しました。

関連する問題