擅长:python、mysql、java
<p>文件是Python中行的迭代器:</p>
<pre><code>for line in file:
output.write(line) # save as is
if 'SAMPLE' in line or 'RUNS' in line:
line = next(file, "") # move to the next line
output.write(line.replace('AB', 'XX')) # save replacing AB with XX
</code></pre>
<p>支持跟在另一个样本/管路之后的采样/管路,例如:</p>
^{pr2}$
<p>你可以:</p>
<pre><code>for line in file:
output.write(line) # save as is
while 'SAMPLE' in line or 'RUNS' in line:
line = next(file, "") # move to the next line
output.write(line.replace('AB', 'XX')) # save replacing AB with XX
</code></pre>