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

来源:互联网 发布:淘宝店铺装修轮播尺寸 编辑:程序博客网 时间:2024/06/05 19:07
# -*-coding:utf-8-*-import restr='''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
原创粉丝点击