字典
d = {
'name':'jake',
'age': 9,
'grade':5,
}
print(d.get('name')) # get 读取字典K对应值的方式
print(d.keys()) # 读取所有K值
print(d.values()) # 读取所有的Value值
print(d.items()) # 读取以元组的形式返回值
c = d.pop('name') #去掉name值
print(c)
print(d)
#字典的更新
c = {
1:1,
2:2
}
c[3]=3
c[4]=4
print(c)
d= {
5:5,
6:6
}
c.update(d)
print(c)
jake
dict_keys(['name', 'age', 'grade'])
dict_values(['jake', 9, 5])
dict_items([('name', 'jake'), ('age', 9), ('grade', 5)])
jake
{'age': 9, 'grade': 5}
{1: 1, 2: 2, 3: 3, 4: 4}
{1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6}