python 删除文本里某段字符串
2019-07-06 本文已影响0人
SkTj
!/usr/bin/python
import os,sys
fi=sys.argv[1]
dd=[]
with open(fi) as f:
c=f.readlines()
for cc in c:
d=cc.split()
if d[3].startswith("[http"):
dd.append(cc.replace(d[3],""))
else:
dd.append(cc)
with open("a","w") as fx:
x=" ".join(dd)
fx.write(x)