>>> for item in itertools.chain([1, 2], ['a', 'b']):
... print(item)
...
1
2
a
b
cycle()
是一个无穷迭代器,会循环遍历其参数:
>>> import itertools
>>> for item in itertools.cycle([1, 2]):
... print(item)
...
1
2
1
2
.
.
.
accumulate() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.