itertools 提供了一系列创建高效循环的的迭代器的函数。
下边汇总该模块的所有功能及介绍,方便后续查询使用。

  • 无限迭代器
迭代器参数描述示例
count()start, step生成固定步长的序列count(10, 2)-> 10 12 14..
cycle()seq无限循环序列cycle('abc')->a b c a b c
repeat()ele, n重复元素n次repeat((1,2,3), 2)->(1,2,3) (1,2,3)

tracer85
1 声望1 粉丝