当前第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中使用while语句[适合初学者]
Python初学者常见的七种错误及解决方法
了解Python 中日志异步发送到远程服务器
Python如何求出输入数的阶乘
Python招聘要求高吗
Python字符串连接的几种方式总结
django源码分析之请求流程
Python中几种存取xls/xlsx文件的方法总结
Python中队列的实现方法(代码示例)
利用Python的socket发送http(s)请求方法
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 什么是python re.match函数?(实例解析)