Python 字典 update() 方法
实例
将项目插入字典:car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
car.update({"color": "White"})
print(car)
运行示例»定义和用法
update()方法将指定的项插入到字典中。
指定的项可以是字典或可迭代对象。
语法
dictionary.update(iterable)
参数值
| Parameter | Description |
|---|---|
| iterable | 字典或一个有键值对的可迭代对象 |
