我要删除此列表中的None值
input= [(None, 'Ibrahimpatnam', 9440627084, None, 'Under Investigation'),
(None, 'Ibrahimpatnam', 9440627084, None, 'Under Investigation')]
并获得类似
的输出['Ibrahimpatnam', 9440627084, 'Under Investigation', 'Ibrahimpatnam', 9440627084, 'Under Investigation']
答案 0 :(得分:0)
尝试一下:
input_= [(None, 'Ibrahimpatnam', 9440627084, None, 'Under Investigation'),
(None, 'Ibrahimpatnam', 9440627084, None, 'Under Investigation')]
output = []
for each in input_:
newList = list(filter(None,each))
output = output+newList
print(output)
注意:请勿将input
用作变量,它是python中的保留关键字。没关系,如果您刚刚在这篇文章中使用过它。