1、c函数update有更新的作用。

2、update()函数用于将两个字典合并操作,有相同的就覆盖

update()方法语法:

dict.update(dict2)

两个字典不存在相同的键

D = {'one':1, 'two':2}

(D).update({'three':3,'four':4})

print(D)

输出:

{‘one’: 1, ‘two’: 2, ‘three’: 3, ‘four’: 4}

两个字典存在相同的键-覆盖

D = {'one':1, 'two':2}

(D).update({'two':3,'four':4})

print(D)

输出:

{‘one’: 1, ‘two’: 3, ‘four’: 4}