Python 使用正则表达式 将一段英文文本切割成 单词列表,使用的语法是:

re.split(r"\b[\.,\s\n\r\n]+?\b",str)

代码如下:

import re
str=''I still have it on my note 3 and holding pretty good,
 I have also dropped my phone about 3 times 
and the case has done it's job, so I am very happy with the case, 
plus it feels very nice on the hand, 
and I like that the camera don't touch the outside anymore. 
happy customer here..''

if __name__ == '__main__':
    word_list=re.split(r"\b[\.,\s\n\r\n]+?\b",str)
    for word in word_list:
        print word

 

相关文章:

  • 2022-12-23
  • 2022-01-13
  • 2021-06-21
  • 2021-09-09
  • 2021-07-17
  • 2022-01-17
  • 2021-08-09
猜你喜欢
  • 2021-05-23
  • 2022-12-23
  • 2021-12-24
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案