Created
June 14, 2011 04:20
-
-
Save lxneng/1024309 to your computer and use it in GitHub Desktop.
merge dict in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> x = {'a': 1, 'b': 2} | |
>>> y = {'b': 10, 'c': 11} | |
>>> z = dict(x.items() + y.items()) | |
>>> z | |
{'a': 1, 'c': 11, 'b': 10} | |
>>> z = dict(x, **y) | |
>>> z | |
{'a': 1, 'c': 11, 'b': 10} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment