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

python学习笔记-使用re模板在字符串中查找所有单词

2016-12-07 10:30 615 查看
re模块的内容

 

re模块中一些重要的函数:



Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import re
>>> pat = '[a-zA-Z]+'
>>> text = '"hello,my name is xiaoming ,how are you?" he said.'
>>> re.findall(pat,text)
['hello', 'my', 'name', 'is', 'xiaoming', 'how', 'are', 'you', 'he', 'said']
>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: