python怎么生成一个嵌套字典,不想使用defaultdict实现

0
Python C/C++ 嵌套字典 33608 次浏览

比如原生的dict属性

test=dict()
test['a']=1         # 这个可以实现
test['x']['y']=2    # 这个就会报错

我想生成一个递归字典,如果没有这个键则创建,哪种方法能简洁点,优雅点~~多谢了

请尽量让自己的答案能够对别人有帮助

41个答案

默认排序 按投票排序
0

Based on the tutorials I watch recently you can simply pass dictionary key:value pair as keyword arguments. Hope this will help you on your defaultdict problem. Please check landscaping aurora il if you are trying to do some landscaping but have no clue about what you are doing then it is time for you to allow us to assume the responsibility of doing it for you. 

0

pg slot true wallet

0

slotxo true wallet

0

Wow, this is interesting but helpful in some way. Thank you for sharing and please check this web link if you're interested about garage epoxy flooring and discover the best garage epoxy flooring contractor who can handle the job hassle-free and efficiently in Colorado Springs, CO. 

0
0
0
0
0
0
0
0
0
0
0

You can try this solution. Hope that can help. Anyway, see this website if you're interested with tree care services. 

0

Can you post the solution here or please update? Thanks! rodent control services

0

This needn't bother with a settled dict, fundamentally. You could slotxo utilize pandas, read_csv, make Device_Name the file, at that point you can legitimately join the two dataframes on their list Device_Name.

0

Thanks for posting and sharing the solution. Hoping for more reliable answer. Thanks! siding Ashburn VA

1 2 3