我有一个与此类似的列表
numbers=[['3','4','5'],['',''],['6','7','8']
我想删除
['','']
完全子列表,所以最终的数字列表应该是
numbers=[['3','4','5'],['6','7','8']]
我试过用
numbers[index].remove('')
但那只是给我一个列表索引超出范围错误
答案 0 :(得分:0)
In [73]: L = [['3','4','5'],['',''],['6','7','8']]
In [74]: dels = []
In [75]: for i,sub in enumerate(L):
....: if all(e=='' for e in sub):
....: dels.append(i)
....:
In [76]: for i in dels[::-1]:
....: L.pop(i)
....:
In [77]: L
Out[77]: [['3', '4', '5'], ['6', '7', '8']]