迭代对象降维至一维:
# coding=utf-8
from collections import Iterable
def oneDim(L):
for each in L:
if not isinstance(each, Iterable) or isinstance(each,str): #保护单词不被拆成一个个字母
yield each
else:
yield from oneDim(each)
if __name__ == "__main__":
L = [1, (2, [3, range(100, 500, 100)]), tuple([5, 6]), ["app","NBA"]]
print(list(oneDim(L)))