How do I merge dictionaries together in Python?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-05-09T20:31:12Z Indexed on 2010/05/09 20:38 UTC
Read the original article Hit count: 122

Filed under:
|
d3 = dict(d1, **d2)

I understand that this merges the dictionary. But, is it unique? What if d1 has the same key as d2 but different value? I would like d1 and d2 to be merged, but d1 has priority if there is duplicate key.

© Stack Overflow or respective owner

Related posts about python

Related posts about dictionary