我有看起来像这样的列表:删除空条目的子列表,从列表
some_list = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h'], ['', '', '', '']]
我想,在列表中删除所有空的子列表,使产品只是
clean_list = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h']]
我已经试过以下
for x in some_list:
if x == ['', '', '', '']:
some_list.remove(x)
和
clean_list = filter(None, list)
和
clean_list = [x for x in list if x]
,但我不断收到输出与空项子列表。思考?
不要使用'list'作为变量,掩盖内置类型。 –