python 日志内容提取
生活随笔
收集整理的這篇文章主要介紹了
python 日志内容提取
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
問題:如下,一個很大的日志文件,提取 start: 到 end: 標志中間的內容
日志文件a.log
xxxxx yyyyy start: start: hahahaha end: start: hahahahha end: ccccccc kkkkkkk cdcdcdcd start: hahahaha end:?
code
import reisfind=False with open("a.log","r") as f:while(1):l=f.readline()if(not l):breakif(re.match("start:", l)):isfind=Trueif(isfind):print(l)if(re.match("end:", l)):isfind=False輸出
start: start: hahahaha end: start: hahahahha end: start: hahahaha end:?
參考:
https://www.cnblogs.com/aaronthon/p/9435967.html
?
轉載于:https://www.cnblogs.com/sea-stream/p/11246484.html
總結
以上是生活随笔為你收集整理的python 日志内容提取的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到自己梦魇了有什么寓意
- 下一篇: 梦到蛇是怀孕的意思吗