擅长:python、mysql、java
<p>或多或少</p>
<pre><code>current_file = None
with open('allzone.txt') as f:
# read line by line
for line in f:
# open next file and close previous
if line.startswith('domain'):
# close previous file
if current_file:
current_file.close()
# open new file
current_file = open(line.strip() + '.txt', 'w')
# write to current file
if current_file:
if not (line.startswith('domain') or line.startswith(' -') or line.startswith('===')):
current_file.write(line)
# close last file
if current_file:
current_file.close()
</code></pre>
<hr/>
<p><strong>编辑:</strong>任何域的新版本</p>
^{pr2}$