python数据类型(四)之嵌套类型
stus = {
"胖妞":
{
"house": ['三环', "四环", "七环"],
"car": {
"日本": ["雷克萨斯", "英菲尼迪"],
"中国": ['五菱宏光', '红旗', '比亚迪', "宝骏"],
"美国": ["福特", "凯迪拉克"]
},
"化妆品": {
"SK-2": 1000,
"YSL": 8000
}
},
"陆明":{
"money":[1000,5000,8000,800000],
"xifu":{
"越南":2,
"伊拉克":10,
"韩国":2,
"泰国":3
}
}
}
1.统计出胖妞总共有多少车
length=0
for i in stus['胖妞']['car'].values{
len=length+len(i)
2.胖妞把比亚迪卖了,换了一个保时捷
car=stus['胖妞'][car]['中国']
car[2]='保时捷'
}