字典.keys() return all the keys
dictionary.values() return all the values
dictionary,items() 返回所有键值对
例如for name,phone in dictionary.items():
执行语句
#字典dictionary的使用
slag_dict={"小明":1350313321,
"小华":2353521211
}#字典的建立,键的类型不可变,字典可以增加覆盖元素
slag_dict["小美"]=132252232#增加值
slag_dict[("张伟",28)]=126353232#元组的值不可变
print(slag_dict)
name=input("请输入您想要查询的人:")
if name in slag_dict:
print("The users phone number is"+str(slag_dict[name]))#查询键对应的值
else:print("He or She is not in the list")
结果: