您的位置:首页 > 编程语言 > Python开发

python正则表达式将字符串切割成单词列表

2017-07-19 14:33 274 查看
# -*-coding:utf-8-*-
import re
str='''I like to read novel books.
When I start    to go to primary school,
my parents have bought me a lot of novel books,
because they want me to fall in love with reading.
Indeed, thanks to these books, I feel very excited about studying
the knowledge. The novel books open my vision and
I am good at writing. I want to write a book and read them
to my families and friends.'''
if __name__ == '__main__':
word_list=re.split(r"\b[\.,\s\n\r\n]+?\b",str)
for word in word_list:
print word
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐