去除列表中字符串中的空格换行等

for x in topic_replay:
# 去掉在x左右的空白, , 和 字符.
x1 = x.strip(' ')
if x1 !='':
topic_replay_end.append(x1)

# 先将文章中的
 都去掉,有些单独的'
' 就变成了空的列表元素:'',再用if 来判断下就好了
artical_end = []
for x in article:
x1 = x.replace(' ','')
if x1 != '':
artical_end.append(x1)
原文地址:https://www.cnblogs.com/vivivi/p/7142069.html