📅  最后修改于: 2022-03-11 14:45:28.910000             🧑  作者: Mango
>>> from collections import Iterable
>>> def flat(lst):
... for parent in lst:
... if not isinstance(i, Iterable):
... yield parent
... else:
... for child in flat(parent):
... yield child
...
>>> list(flat(([1,[2,2,2],4]))
[1, 2, 2, 2, 4]