擅长:python、mysql、java
<p>试试这个:</p>
<pre><code>with open('honeyd.txt') as f:
lines = [line.strip().split() for line in f] # a list of lists
for i in range(len(lines)):
with open('test_{}.rule'.format(i), 'w') as f2:
f2.write("alert {} {} -> {} {}\n".format(*lines[i]))
</code></pre>