要求:
# -- coding: utf-8 --
import os
rootdir = ‘d:/a’
savedir = ‘d:/b’
list = os.listdir(rootdir)
for i in range(0,len(list)):
path = os.path.join(rootdir,list[i]).replace(‘\’,’/’)
if os.path.isfile(path):
#读取文件
with open(path,”r”) as f:
lines = f.readlines()
#写文件
with open(path,”w”) as f_w:
for line in lines:
if “there is problem” not in line:
continue
f_w.write(line)
f.close()
f_w.close()