Python生成字典嵌套


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}})

猜你喜欢

转载自blog.csdn.net/wu0che28/article/details/81462538