طريقة تحديث قاموس بايثون
مثال
أدخل عنصرًا في القاموس:
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
car.update({"color": "White"})
print(car)
التعريف والاستخدام
تقوم update()
الطريقة بإدراج العناصر المحددة في القاموس.
يمكن أن تكون العناصر المحددة قاموسًا ، أو كائنًا متكررًا بأزواج قيم مفتاح.
بناء الجملة
dictionary.update(iterable)
قيمه المعامل
Parameter | Description |
---|---|
iterable | A dictionary or an iterable object with key value pairs, that will be inserted to the dictionary |