擅长:python、mysql、java
<p>我不确定您到底做了什么,但您可能会发现<a href="http://docs.python.org/library/stdtypes.html#dict.setdefault" rel="nofollow noreferrer">setdefault</a>有用:</p>
<blockquote>
<p><strong>setdefault(key[, default])</strong></p>
<blockquote>
<p>If key is
in the dictionary, return its value.
If not, insert key with a value of
default and return default. default
defaults to None.</p>
</blockquote>
</blockquote>
<p>详细信息:<a href="https://stackoverflow.com/questions/3483520/use-cases-for-the-setdefault-dict-method">Use cases for the 'setdefault' dict method</a></p>