Python 3.x 在python 3.0中,如何从列表列表中删除空字符串?

Python 3.x 在python 3.0中,如何从列表列表中删除空字符串?,python-3.x,Python 3.x,如果我打印名为文本的列表: print(text) 返回将显示以下内容 [['this', 'example', '',], ['a','b','']] 如何从这里删除空字符串?使用列表: text = [['this', 'example', '',], ['a','b','']] print([[string for string in sublist if string] for sublist in text]) # [['this', 'example'], ['a', 'b']

如果我打印名为文本的列表:

print(text)
返回将显示以下内容

[['this', 'example', '',], ['a','b','']]

如何从这里删除空字符串?

使用列表:

text = [['this', 'example', '',], ['a','b','']]
print([[string for string in sublist if string] for sublist in text])
#  [['this', 'example'], ['a', 'b']]
可能重复的