删除字符串列表中的单词

时间:2020-09-19 13:33:51

标签: python python-3.x list

我想删除短语中的单词。

例如,我有这段:


Do you know what would be amazingly awesome? BOS-FLL PLEASE!!!!!!! I want to fly with only you.

 I love this graphic.

 amazing customer service, again!  <3  <3  RaeAnn in SF - she's the best! #customerservice 
 Love the team running Gate E9 at LAS tonight. Waited for a delayed flight, and they kept things entertaining

 you have the absolute best team and customer service ever.  Every time I fly with you I'm delighted.  Thank you!

我在列表中有4个词组,我想删除每个单词,例如“ the”。

我尝试过:

for i in tweets_dev:
    i.replace("the"," ")
    print(i)

但是没有用!

我的名单上总是有“ the”。请指导我主要错误是什么,以及如何执行上述任务。预先感谢。

感谢阅读

1 个答案:

答案 0 :(得分:0)

尝试
tweets_dev.lower().replace(' the ', ' ')

输出:

 i love this graphic.

 amazing customer  service, again!  <3  <3  raeann in sf - she's best! #customerservice
 love team running gate e9 at las tonight. waited for a delayed flight, and they kept things entertaining

 you have absolute best team and customer service ever.  every time i fly with you i'm delighted.  thank you!```