擅长:python、mysql、java
<p>使用<code>itertools.zip_longest()</code>for Python 3,可以处理任意数量的输入列表:</p>
<pre><code>>>> from itertools import zip_longest
>>> [next(x for x in t if x is not None) for t in zip_longest(a,b,c,d)]
[1, 2, 3, 8, 6, 7]
</code></pre>
<p>默认的填充值是<code>None</code>,因此在使用<code>zip_longest</code>调用创建的每个元组中使用第一个none <code>None</code>元素(如果<code>None</code>是有效的数据值,则可以更改默认值和条件)</p>