擅长:python、mysql、java
<p>在这里不要使用<code>regex</code>。检查当前行,如果是要检查的行,则添加新行。你知道吗</p>
<pre><code>with open("output.txt", "w") as out_file:
for line in readcontent:
out_file.write(line)
if line.strip() == 'Can you hear me?':
out_file.write('\n')
</code></pre>
<p>如果您需要一个<code>regex</code>本身,请选择以下内容(尽管我从不推荐):</p>
<pre><code>with open("output.txt", "w") as out_file:
for line in readcontent:
out_file.write(line)
if re.match('Can you hear me?', line.strip()):
out_file.write('\n')
</code></pre>