字典的嵌套:
举一个简单的例子
wangfeng = {
"name'' : "汪峰"
"age" :18
"wife": {"章子怡"
"hobby" : "演习"
"assistant": {
"name" : ''A"
"age" : "19"
"hobby" : "吃饭"
}
}
"children" : [
{"name" : "a","age" : 13}
{"name" : "b","age" : 10}
{"name" : "c","age" : 8}
]
}
name =wangfeng ['wife']['assistant']['name']
print(name)
给汪峰的第二个孩子加一岁
wangfeng['children'][1]['age'] = wangfeng['children'][1]['age'] + 1
字典的增删改查
dic = dict()
dic['jay'] = "周杰伦"
# 此时,如果字典中已经有了jay,那么此时执行的就是修改操作。