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)

  

相关文章:

  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-11-04
  • 2022-12-23
相关资源
相似解决方案