What is the best way to implement nested dictionaries?

后端 未结 21 1801
[愿得一人]
[愿得一人] 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:54

    Just because I haven't seen one this small, here's a dict that gets as nested as you like, no sweat:

    # yo dawg, i heard you liked dicts                                                                      
    def yodict():
        return defaultdict(yodict)
    

提交回复
热议问题