改
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
dic1 = {'age':16,'name':'套你大象','sex':',male','weight':'67'} dic2 = {'age':45,'sex':',male'} dic2.update(dic1)#将dict1中的数据更新到dict2中,有更改,没有添加 print(dic1) print(dic2)
![](https://i-blog.csdnimg.cn/blog_migrate/d2edb6c0ef582a59e1447ff0285ebf5b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
dic1 = {'age':16,'name':'套你大象','sex':',male','weight':'67'} dic1['age'] = '19' print(dic1)
查
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
dic1 = {'age':16,'name':'套你大象','sex':',male','weight':'67'} print(dic1.keys())#键 print(dic1.items())#值 print(dic1.values())#元组,元组中含有键值
![](https://i-blog.csdnimg.cn/blog_migrate/1ff4eaf4fb80f1a781d480692c4cf937.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
dic1 = {'age':16,'name':'套你大象','sex':',male','weight':'67'} # print(dic1.keys())#键 # print(dic1.items())#值 # print(dic1.values())#元组,元组中含有键值 for i in dic1.values(): print(i)
![](https://i-blog.csdnimg.cn/blog_migrate/61f658d2d305550441417185ab007691.png)
也可以使用for循环来查询,其他两个类似。
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
dic1 = {'age':16,'name':'套你大象','sex':',male','weight':'67'} l = dic1['age']#直接返回值,但是若字典中没有这个键,则会报错 print(l)
![](https://i-blog.csdnimg.cn/blog_migrate/d7e00afe2851584fbdccacfce8c181b6.png)