擅长:python、mysql、java
<p>如果不介意外部依赖项,可以包括<a href="http://werkzeug.pocoo.org/documentation/0.6.2/datastructures.html#werkzeug.MultiDict" rel="nofollow noreferrer">Werkzeug's MultiDict</a>:</p>
<blockquote>
<p>A MultiDict is a dictionary subclass customized to deal with multiple values for the same key which is for example used by the parsing functions in the wrappers.</p>
</blockquote>
<pre><code>>>> d = MultiDict([('a', 'b'), ('a', 'c')])
>>> d
MultiDict([('a', 'b'), ('a', 'c')])
>>> d['a']
'b'
>>> d.getlist('a')
['b', 'c']
>>> 'a' in d
True
</code></pre>
<p>为键存储多个值的另一种方法是使用容器类型,如<code>list</code>、<code>set</code>或<code>tuple</code>。</p>