如题,俺就直抒胸臆了
之所以要这么钻牛角尖,是因为在俺的那个项目中,list比较大,如果要转numpy,numpy再tolist,无疑会造成内存的浪费,俺感到很不爽,因此开发了这个方法
def down(lst):
out = list()
for obj in lst:
if isinstance(obj, list):
out += obj
if len(out) == 0:
return lst
else:
return out
def down_n(lst):
while True:
if lst == down(lst):
return lst
else:
lst = down(lst)
a = [[["1", "2", "3"], ["1", "2", "3"]]]
print(down_n(a))