python 正则表达式模块 re,提供正则匹配操作;
正则表达式的内容这里就不过多的阐述了,有兴趣的请查看http://www.runoob.com/regexp/regexp-syntax.html
本文主要讲解python中re模块的运用
- re.match # 从开头开始匹配
# 匹配开头
>>> import re
>>> con = re.match("Type","Type copyright")
>>> con.group()
'Type'
# 如果匹配不是开头的字符串,就会是一个None
>>> import re
>>> con = re.match("copy","Type copyright")
>>> print(con)
None
2310

被折叠的 条评论
为什么被折叠?



