python 中re模块

 

001、match

>>> import re
>>> str1 = "www.baidu.com"            ## 测试字符串
>>> re.match("www", str1)
<re.Match object; span=(0, 3), match='www'>
>>> re.match("www", str1).span()      ## 返回匹配的范围
(0, 3)

 

posted @ 2022-11-16 16:21  小鲨鱼2018  阅读(21)  评论(0编辑  收藏  举报