随笔-生活工作点滴

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)

上一篇 下一篇

猜你喜欢

热点阅读