字典的更新update方法的使用

update方法:对于字典a,通过b来更新:如果a字典中存在b字典中的key-value值,则对a进行更新,不存在的值则插入

info={
    'stu1001':'tenglan wu',
    'stu1002':'longze luola',
    'stu1003':'xiaozee mali',
}
update_b={
    'stu1001':'masheng xi',
    'reader': 'one',
    'match':'li sir'
}
info.update(update_b)#根据字典updata_b更新字典info,存在的值则更新,不存在的值则插入
print(info)

  

posted on 2017-10-14 16:12  Alan_chow  阅读(1097)  评论(0编辑  收藏  举报

导航