#第一种:
while '' in test:
test.remove('')
#第二种:
mytest = [i for i in test if i != '']
如果遇到一些复杂的问题,不得不有对原列表进行增删操作,可以考虑递归。
转载请注明:源码巴士 » python去除列表中的空元素
#第一种:
while '' in test:
test.remove('')
#第二种:
mytest = [i for i in test if i != '']
如果遇到一些复杂的问题,不得不有对原列表进行增删操作,可以考虑递归。
转载请注明:源码巴士 » python去除列表中的空元素