📜  python 展平列表列表 - Python 代码示例

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

代码示例4
from collections.abc import Iterable

def flatten(l):
    for el in l:
        if isinstance(el, Iterable) and not isinstance(el, (str, bytes)):
            yield from flatten(el)
        else:
            yield el