擅长:python、mysql、java
<p>可以使用itertools包中的<a href="https://docs.python.org/3.6/library/itertools.html#itertools.tee" rel="nofollow noreferrer">tee</a>函数创建<code>n</code>个不同的迭代器。然后分别对它们进行迭代:</p>
<pre><code>from itertools impor tee
i1, i2 = tee(tuple_gen, n=2)
firsts = (x[0] for x in i1)
seconds = (x[1] for x in i2)
</code></pre>