3.字典的嵌套
wf = { "name":"汪峰", "age":52, "hobby":["唱歌", "上头条", "穿皮裤"], "wife": { "name": "章子怡", "age": 49, "hobby":["演戏", "上电视", "当导师"], "tishen": { "name":"萌萌", "age":28 }, "zhuli":{ "name":"磊磊", "age": 20 } }, "zhuli":{ "name":"宝宝", "age":23, "hobby":["抽烟","喝酒","烫头"] }, "children":[{"name":"汪老大"}, {"name":"汪老二"}] } # wf['children'][1]["age"] = 2 # print(wf) # # print(wf['zhuli']['name']) # # # 汪峰老婆替身的名字 # print(wf['wife']['tishen']['name']) # # 汪峰老婆的第二个爱好 # print(wf['wife']['hobby'][1]) # # 汪峰助理的第三个爱好 # print(wf['zhuli']['hobby'][2]) # # # # 汪峰的助理+10岁 # wf['zhuli']['age'] = wf['zhuli']['age'] + 10 # # 汪峰的老婆添加一个爱好("导戏") # wf['wife']['hobby'].append("导戏") # 添加完毕了 # # 删除汪峰助理的"抽烟"爱好 # wf["zhuli"]["hobby"].remove("抽烟") # print(wf)