擅长:python、mysql、java
<p>怎么样</p>
<pre><code> import re
mfcList1, ctrlList1 = [],[]
# read the whole file as a list of lines - its easier
with open(file1, 'r') as f1:
lines = f1.readlines()
# for each line, search for your string.
# If you have found MegaMon append one mfcList1, else append ctrlList1
foundMegaMon = False
for line in lines:
if re.search("MegaMon> mfc",line):
foundMegaMon = True
if foundMegaMon:
mfcList1.append(line)
else:
ctrlList1.append(line)
</code></pre>