修正了我自己的问题。下面的工作是查找一个特定的行并获得匹配行之后的行。在def match_text(raw_data_file, match_this_text):
w = match_this_text
lines = ""
with open(raw_data_file, 'r') as inF:
for line in inF:
if w in line:
lines += line //Will add the matched text to the lines string
for i in range(0, however_many_lines_after_matched_text):
lines += next(inF)
//do something with 'lines', which is final multiline text
用户希望返回多行匹配的字符串。如果这个问题让人困惑,我很抱歉。在