info = {
"person1":"大s",
"person2":"小s",
"person3":"小3",
"person4":"小4"
}
info["person5"]="小5"
info = {
"广东" : {
"深圳":["罗湖", "福田", "南山"],
"广州":["天河", "番禺", "白云"],
},
"浙江" : {
"杭州":["西湖","下城","上城"],
"温州":["龙湾","瑞安"],
},
"江苏" : {
"苏州":["沧浪","平江","吴中"],
"南京":["白下","浦口","你好"],
}
}
info["湖南"]={"长沙":[1,2,3]}
#增加了一个key为湖南的内容
info = {
"person1":"大s",
"person2":"小s",
"person3":"小3",
"person4":"小4"
#---------key----value------
}
del info["person4"]
info = {
"person1":"大s",
"person2":"小2",
"person3":"小3",
"person4":"小4"
#---------key----value------
}
info["person1"] = "大1"
info = {
"广东" : {
"深圳":["罗湖", "福田", "南山"],
"广州":["天河", "番禺", "白云"],
},
"浙江" : {
"杭州":["西湖","下城","上城"],
"温州":["龙湾","瑞安"],
},
"江苏" : {
"苏州":["沧浪","平江","吴中"],
"南京":["白下","浦口","你好"],
}
}
info["江苏"]["南京"] = [1,2,3]
print(info["江苏"]["南京"])
#结果:[1,2,3]
info = {
"person1":"大s",
"person2":"小2",
"person3":"小3",
"person4":"小4"
#---------key----value------
}
print(info.get("person1")) #此方法如果主键不存在,也不会报错
print(info["person1"]) #此方法跟上面一样,但如果主键不存在,系统报错
info = {
"广东" : {
"深圳":["罗湖", "福田", "南山"],
"广州":["天河", "番禺", "白云"],
},
"浙江" : {
"杭州":["西湖","下城","上城"],
"温州":["龙湾","瑞安"],
},
"江苏" : {
"苏州":["沧浪","平江","吴中"],
"南京":["白下","浦口","你好"],
}
}
print(info["江苏"])
#结果:{'苏州': ['沧浪', '平江', '吴中'], '南京': ['白下', '浦口', '你好']}
print(info["江苏"]["苏州"])
#结果:['沧浪', '平江', '吴中']
info = {
"广东" : {
"深圳":["罗湖", "福田", "南山"],
"广州":["天河", "番禺", "白云"],
},
"浙江" : {
"杭州":["西湖","下城","上城"],
"温州":["龙湾","瑞安"],
},
"江苏" : {
"苏州":["沧浪","平江","吴中"],
"南京":["白下","浦口","你好"],
}
}
for i in info:
print(i,info[i])
#结果:
广东 {'深圳': ['罗湖', '福田', '南山'], '广州': ['天河', '番禺', '白云']}
浙江 {'杭州': ['西湖', '下城', '上城'], '温州': ['龙湾', '瑞安']}
江苏 {'苏州': ['沧浪', '平江', '吴中'], '南京': ['白下', '浦口', '你好']}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
成都创新互联是专业的颍东网站建设公司,颍东接单;提供成都网站建设、网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行颍东网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!