擅长:python、mysql、java
<p>另一种分组ITerable的方法,来自<a href="http://docs.python.org/library/itertools.html" rel="nofollow">itertools</a>示例:</p>
<pre><code>def grouper(n, iterable, fillvalue=None):
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return izip_longest(fillvalue=fillvalue, *args)
</code></pre>