#!/usr/bin/env?python
#coding=utf-8
def?read_del_list(path):
del_list?=?list()
with?open(path,?'w')?as?file_handle:
for?row?in?file_handle:
del_list.append(row.strip())
return?del_list
def?filte_file(from_file,?to_file,?del_list):
with?open(from_file)?as?file_handle_from:
with?open(to_file)?as?file_handle_to:
for?row?in?file_handle_from:
if?not?any(key_word?in?row?for?key_word?in?del_list):
file_handle_to.write(row)
if?__name__?==?'__main__':
del_list?=?read_del_list(r"del_list.txt")#读取过滤规则
filte_file(r"source.txt",?"output.txt",?del_list)#过滤文件