当前第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零基础新手入门小知识
Python中基本的数据结构--列表
Python编程如何判别线性
Python质数如何判断
Python如何在 .format 中使用大括号
Python如何把列表变字典
Python中集合中的元素是否可以重复
Python并发处理asyncio包如何使用
Python中数据预处理(代码)
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 什么是python re.match函数?(实例解析)