我有一个列表列表的列表...
A = [ [[1,3]], [[3,5], [4,4], [[5,3]]] ]
以下函数输出[1, 3, 3, 5, 4, 4, 5, 3]
def flatten(a):
b = []
for c in a:
if isinstance(c, list):
b.extend(flatten(c))
else:
b.append(c)
return b
但是,我想停止在最后一级变平,以便我得到[ [1,3], [3,5], [4,4], [5,3] ]