当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 | # !/usr/bin/python
import re
line = "Cats are smarter than dogs"
matchObj = re.match(r '(.*) are (.*?) .*' , line, re.M | re.I)
if matchObj:
print "matchObj.group() : " , matchObj.group()
print "matchObj.group(1) : " , matchObj.group(1)
print "matchObj.group(2) : " , matchObj.group(2)
else :
print "No match!!"
|
以上实例输出如下:
1 2 3 4 5 | matchObj.group() : Cats are smarter than dogs
matchObj.group(1) : Cats
matchObj.group(2) : smarter
|
以上就是本篇文章所讲述的所有内容,这篇文章主要介绍了python中re.match函数的相关知识,希望你能借助资料从而理解上述所说的内容。希望我在这片文章所讲述的内容能够对你有所帮助,让你学习python更加轻松。
更多相关知识,请访问php中文网Python教程栏目。
以上就是什么是python re.match函数?(实例解析)的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python语言是干什么的
Python 解决中文写入excel时抛异常的问题
Python学会了可以干什么
selenium+Python如何爬取简书网站
Python中filecmp的简单使用
Python3.6.4如何安装到树莓派3代
Python库怎么安装
Python怎么做反爬
Python异常和错误有什么区别
Python中的排序操作和heapq模块的介绍(代码示例)
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 什么是python re.match函数?(实例解析)