# Auther: Aaron Fan
info = {
"stull01":"alen zhang",
"stull02":"si li",
"stull03":"san zhang",
}
#查
print(info)
print(info["stull01"])
print(info.get("stull04")) #有就返回它的值,沒有就為None
print("stull03" in info) #判斷一個鍵是否在一個字典里面,有就True沒有就False
#python2.7里面有一個和這個效果一模一樣的用法:info.has_key("stull03"),這個方法只適用python2,python3里面已經沒有這種方法了,注意一下就行了
#改
info["stull02"] = "李四"
print(info)
#增
info["stull04"] = "小王"
print(info)
#刪
del info["stull04"] #注意永久性的刪除
info.pop("stull03") #彈出,跟列表里面的pop用法一樣,可以去參考一下
test1 = info.popitem() #隨機彈出
print(info)
print(test1)