去掉多层嵌套列表

D = []
def move_list(a):
    for i in a :
        if type(i) != list:
            D.append(i)
        else:
            move_list(i)
s=[1,[12,[1,[1,23,4,[1,2,[3]]]]],[3,[1,[2,645,[3,5,[456,[4,[45,7,[2,[[[[[[5]]]]]]]]]]]]],4]]
move_list(s)
print(D)

 

posted @ 2019-09-17 15:18  给我买AJ  阅读(435)  评论(0编辑  收藏  举报