擅长:python、mysql、java
<p>使用<a href="http://docs.python.org/2/reference/expressions.html#generator-expressions" rel="nofollow"><em>generator expression</em></a>和<a href="http://docs.python.org/2/library/functions.html#max" rel="nofollow"><strong>^{<cd1>}</strong></a>:</p>
<pre><code>In [10]: index = 0
In [11]: dictA = { 1 : [22, 31, 14], 2 : [9, 4, 3], 3 : [77, 15, 23]}
In [12]: max(l[index] for l in dictA.itervalues())
Out[12]: 77
</code></pre>
<p>注意:<a href="http://docs.python.org/2/library/stdtypes.html#dict.itervalues" rel="nofollow">^{<cd2>}</a>返回字典值上的<a href="http://docs.python.org/2/library/stdtypes.html#iterator-types" rel="nofollow"><em>iterator</em></a>,而不进行<em>复制</em>,因此比<a href="http://docs.python.org/2/library/stdtypes.html#dict.values" rel="nofollow">^{<cd3>}</a>(在Python<;3中)效率更高。</p>