In [2]: from collections import defaultdict
In [3]: a = defaultdict(dict)
In [4]: a['hell']['good']= 1
In [5]: a
Out[5]: defaultdict(<type 'dict'>, {'hell': {'good': 1}})
Python生成字典嵌套
最新推荐文章于 2024-06-26 10:45:28 发布
In [2]: from collections import defaultdict
In [3]: a = defaultdict(dict)
In [4]: a['hell']['good']= 1
In [5]: a
Out[5]: defaultdict(<type 'dict'>, {'hell': {'good': 1}})