擅长:python、mysql、java
<pre><code>>>> a2dList=[['a','1','2','3','4'],['b','5','6','7','8']]
>>> otherList = [9,8,7,6,5]
>>> for x, y in zip(a2dList, otherList):
x.append(y)
>>> a2dList
[['a', '1', '2', '3', '4', 9], ['b', '5', '6', '7', '8', 8]]
</code></pre>
<p>在Python2.x上,考虑使用<code>itertools.izip</code>代替延迟压缩:</p>
^{pr2}$
<p>还要注意,<code>zip</code>将在到达最短iterable的末尾时自动停止,因此如果<code>otherList</code>或{<cd4>}只有<code>1</code>项,此解决方案将不会出错,按索引修改列表会有这些潜在问题的风险。在</p>