文章摘要:python遍历嵌套列表 python嵌套列表怎么遍历
在python中使用decompose函数对嵌套列表进行遍历,具体方法如下: def decompose(co […]
在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)