delete specific lines in a set of files in a folder

import os 

myinst = ['foo','bar']

def wipe_lines(folder):
    for (dirpath, dirnames, filenames) in os.walk('/Users/faramir/git/'+ folder):
        for filename in filenames:
            f = open(os.sep.join([dirpath, filename]),"r")
            lines = f.readlines()
            f.close()
            f = open(os.sep.join([dirpath,filename]),"w")
            for line in lines:
                if not line in copyright:
                    f.write(line)

for x in ['mos','unittest']:
    wipe_lines(x)


展开阅读全文

没有更多推荐了,返回首页

应支付0元
点击重新获取
扫码支付

支付成功即可阅读