我已经有密码了
#!usr.bin/env pyhton
asal = open("honeyd.txt")
tujuan = open("test.rule", "W")
satu = asal.readline()
a = satu.split();
b = 'alert ' + a[0]+' ' + a[1] + ' -> ' + a[2]+' '+ a[3]
c = str(b)
tujuan.write(c)
asal.close()
tujuan.close()
但这段代码只是读一行然后把它分开。 实际上,我的霍尼德.txt" 我的目标是分开所有的线。在
如何拆分所有行并将其保存为“测试规则"? 在
您需要循环输入行;现在只调用
readline
一次。直接在输入文件句柄上循环即可达到最佳效果:还要注意
with
语句的使用,这使您不必手动调用close
。在相关问题 更多 >
编程相关推荐