首页 > 编程语言 > 详细

Python 使用正则表达式 将一段英文文本切割成 单词列表

时间:2020-03-23 13:58:37      阅读:401      评论:0      收藏:0      [点我收藏+]

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 its job, so I am very happy with the case, 
plus it feels very nice on the hand, 
and I like that the camera dont 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

 

Python 使用正则表达式 将一段英文文本切割成 单词列表

原文:https://www.cnblogs.com/shenxiaolin/p/12551526.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!