鱼C论坛's Archiver
论坛
›
Python交流
› python将嵌套的list打平
糖逗
发表于 2023-1-31 11:25:17
python将嵌套的list打平
#打平嵌套的list
def flat1(inputlist, result = None):
if result is None:
result = []
for item in inputlist:
if isinstance(item, list):
flat1(item, result)
else:
result.append(item)
return result
页:
[1]
查看完整版本:
python将嵌套的list打平