擅长:python、mysql、java
<p>python3中的<code>map</code>是一个迭代器,而在python2中,它计算一个列表。所以,你要找的是<a href="https://stackoverflow.com/q/21210633/198633">a way to consume the entire iterator</a>。谢天谢地,这里有<a href="http://docs.python.org/2/library/itertools.html#recipes" rel="nofollow noreferrer">an ^{<cd2>} recipe</a>:</p>
<pre><code>import collections
def extractFromZipFiles(zipFiles, files, toPath):
extractFunction = lambda fileName:zipFiles.extract(fileName, toPath)
collections.deque(map(extractFunction,files), maxlen=0)
return
</code></pre>