# 字典 给字典赋值
dict3={}
dict3[1]='abc'
dict3['1']=3.1215926
dict3[3.2]='xyz'
print(dict3) # {1: 'abc', '1': 3.1215926, 3.2: 'xyz'}
# 修改
dict3[1]="ggg"
print(dict3) # {1: 'ggg', '1': 3.1215926, 3.2: 'xyz'}
# 判断 key是否存在
print(1 in dict3) # 存在 True
# 判断 value是否存在
print('ggg' in dict3.values()) # 存在 True
# 删除
del dict3[1]
print(dict3) # {'1': 3.1215926, 3.2: 'xyz'}
# 获取删除的value
print(dict3.pop(3.2)) # xyz
print(dict3) # {'1': 3.1215926}
student_info={'Jack':14,'Tom':18,'Rob':16}
# 遍历
for name,age in student_info.items():
print(name,age)
'''
Jack 14
Tom 18
Rob 16
'''
for name in student_info:
print('name:%s,age:%s'%(name,student_info[name]))
'''
name:Jack,age:14
name:Tom,age:18
name:Rob,age:16
'''