运维网's Archiver
论坛
›
Python
› Python 正则 提取由start开始到end结束的行
十二12
发表于 2017-5-9 06:41:29
Python 正则 提取由start开始到end结束的行
import re
s=open(r"bug.txt").read()
regexpr=re.compile(r"start(.*?)end",re.DOTALL)
result=regexpr.search(s)
try:
print result.group(1)
except:
print "Can't find match string"
页:
[1]
查看完整版本:
Python 正则 提取由start开始到end结束的行