How to grab the lines AFTER a matched line in python

前端 未结 4 1330
[愿得一人]
[愿得一人] 2021-01-05 12:22

I am an amateur using Python on and off for some time now. Sorry if this is a silly question, but I was wondering if anyone knew an easy way to grab a bunch of lines if the

4条回答
  •  清歌不尽
    2021-01-05 13:26

    I don't really know Python, but here's a bit of pseudocode.

    int header_found=0;

    [start where loop where you're looping through lines of file]

    if(header_found==1) [grab line]; header_found=0;

    if(line=~/[regexp for header]/) header_found=1;

    The idea is to have a variable that keeps track of whether or not you've found a header, and if you have, to grab the next line.

提交回复
热议问题