擅长:python、mysql、java
<pre><code>>>> dict_merge = lambda a,b: a.update(b) or a
>>> dict_merge({'a':1, 'b':3},{'c':5})
{'a': 1, 'c': 5, 'b': 3}
</code></pre>
<p>注意,除了返回合并的dict之外,它还修改了第一个参数。所以dict_merge(a,b)将修改a</p>
<p>或者,当然,你也可以直接做:</p>
<pre><code>>>> (lambda a,b: a.update(b) or a)({'a':1, 'b':3},{'c':5})
{'a': 1, 'c': 5, 'b': 3}
</code></pre>