擅长:python、mysql、java
<p>看起来您想要<code>roundrobin</code><a href="https://docs.python.org/2/library/itertools.html#recipes" rel="noreferrer">^{<cd2>} recipe</a>:</p>
<pre><code>def roundrobin(*iterables):
"roundrobin('ABC', 'D', 'EF') > A D E B F C"
# Recipe credited to George Sakkis
pending = len(iterables)
nexts = cycle(iter(it).next for it in iterables)
while pending:
try:
for next in nexts:
yield next()
except StopIteration:
pending -= 1
nexts = cycle(islice(nexts, pending))
</code></pre>
<p>使用中:</p>
^{pr2}$