擅长:python、mysql、java
<p>考虑使用<a href="http://docs.python.org/2/library/stdtypes.html#dict.get" rel="nofollow">^{<cd1>}</a>。你知道吗</p>
<p>您可能需要执行类似<code>mydict.get("Foo", {}).get(ct, {}).get(ch):</code>的操作。基本上得到一个默认的空<code>dict</code>,它将在最后默认为nothing。你知道吗</p>
<p>或者,使用<code>in</code>验证密钥。你可能有</p>
<pre><code>if ct in mydict['foo'] and ch in mydict['foo'][ct]:
</code></pre>
<p>它不应该因为Python中的延迟计算而失败。你知道吗</p>