在python中使用decompose函数对嵌套列表进行遍历,具体方法如下:
def decompose(com):
types = [list, tuple, set]
tmpType = type(com)
if tmpType in types:
for item in com:
decompose(item)
else tmpeType == dict:
for item in com:
decompose(com[item])
else:
print(com)
lis = [["k",["qwe",20,{"k1":["tt",3,"1"]},89],"ab"]]
decompose(lis)