擅长:python、mysql、java
<p>这是一个紧凑的版本,但你的完全可以:</p>
<pre><code>from collections import defaultdict
d1 = {'a': 1, 'b': 1, 'c': 1, 'd': 1}
d2 = {'a': 90, 'b': 89, 'x': 45, 'd': 90}
l = 90
# The default (==0) is a substitute for the condition "not in d2"
# As daniel suggested, it would be better if d2 itself was a defaultdict
d3 = defaultdict(int, d2)
print [ (k, d3[k]) for k in d1 if d3[k] < l ]
</code></pre>
<p>输出:</p>
<pre><code>[('c', 0), ('b', 89)]
</code></pre>