📜  itertools .cycle() - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:15.091000             🧑  作者: Mango

代码示例1
def cycle(iterable):
    # cycle('ABCD') --> A B C D A B C D A B C D ...
    saved = []
    for element in iterable:
        yield element
        saved.append(element)
    while saved:
        for element in saved:
              yield element