Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created June 14, 2011 04:20
Show Gist options
  • Save lxneng/1024309 to your computer and use it in GitHub Desktop.
Save lxneng/1024309 to your computer and use it in GitHub Desktop.
merge dict in python
>>> 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