python基础—字典的使用{}_多级字典嵌套

shpping_catalog = {
'food':{
'fish':['delisious','aaaa'],
'meat':['oil','bbbb'],
'fruit':['fresh','cccc'],
'vegetables':['healthy','dddd']
},
'drink':{
'milk':['good','eeee']
},
'play':{
'football':['great','ffff','gggg']
}
}
shpping_catalog['play']['football'][2] = 'hhhh'
print(shpping_catalog)
print(shpping_catalog.values())
print(shpping_catalog.keys())
shpping_catalog.setdefault('work',{'pen':['black','red']})#取不到work,增加一个key,value,取得到就是原来的值
print(shpping_catalog)
上一篇:idea创建maven项目速度慢?别急,这有三种方案


下一篇:mysql占用CPU超过100%解决过程