我在
运行示例Detecting consecutive integers in a list
from itertools import groupby
from operator import itemgetter
data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
for k, g in groupby(enumerate(data), lambda ix: ix[0] - ix[1]):
result = list(map(itemgetter(1), g))
print (result)
for t in g:
print(t)
但循环中的第二个打印无法打印出任何内容。
为什么会这样?