016_dict

#!/usr/bin/env python
# Author:liujun

info = {
'stu1101':"TenglanWu",
'stu1102':"LongzaLuola",
'stu1103':"XiaoZeMaliya",
'stu1104':"TenglanWu",
'stu1105':"LongzaLuola",
'stu1106':"TenglanWu",
'stu1107':"LongzaLuola",
'stu1108':"TenglanWu",
'stu1109':"LongzaLuola",
'stu1110':"TenglanWu",
'stu1111':"LongzaLuola",
}


print(info["stu1101"])
# an error ocurred if it doesn't exist.
print(info.get('stu1103'))
# return null if it doesn't exist.
print('stu1104' in info)
# Determine if it exists.



info["stu1101"] = "canglaoshi"
# Modify if it exists,otherwise create a new element.




del info["stu1101"]
info.pop("stu1102") # At least one arguments is given
# delete an element
info.popitem()
# Randomly delete an element




av_catalog = {
"Am":{
"www.youporn.com": ["很多免费的,世界最大的","质量一般"],
"www.pornhub.com": ["很多免费的,也很大","质量比yourporn高点"],
"letmedothistoyou.com": ["多是自拍,高质量图片很多","资源不多,更新慢"],
"x-art.com":["质量很高,真的很高","全部收费,屌比请绕过"]
},
"japan":{
"tokyo-hot":["质量怎样不清楚,个人已经不喜欢日韩范了","听说是收费的"]
},
"china":{
"1024":["全部免费,真好,好人一生平安","服务器在国外,"]
}
}
av_catalog["china"]["1024"][1] = "The web is in abroad"

print(info.keys())
# Print all keys
print(info.values())
# Print all values
print(info.items())


av_catalog.setdefault("taiwan",{"WWW.baidu.com":[1,2]})
av_catalog.setdefault("china",{"1025":["xxxxxxxxxxxxx","ppppppppppppppppp"]})
# Create a new element if it doesn't exist,otherwise return its value.

av_catalog.update(info)
print(av_catalog)



for i in info: # recommanded
print(i,info[i])
for k,v in info.items():
print(k,v)

posted on 2018-09-04 21:14  langjitianyadaolao  阅读(404)  评论(0编辑  收藏  举报

导航