What is the best way to implement nested dictionaries?

后端 未结 21 1828
[愿得一人]
[愿得一人] 2020-11-22 00:29

I have a data structure which essentially amounts to a nested dictionary. Let\'s say it looks like this:

{\'new jersey\': {\'mercer county\': {\'plumbers\':          


        
21条回答
  •  醉酒成梦
    2020-11-22 00:32

    You can use Addict: https://github.com/mewwts/addict

    >>> from addict import Dict
    >>> my_new_shiny_dict = Dict()
    >>> my_new_shiny_dict.a.b.c.d.e = 2
    >>> my_new_shiny_dict
    {'a': {'b': {'c': {'d': {'e': 2}}}}}
    

提交回复
热议问题