當前位置:成語大全網 - 漢語詞典 - python如何刪除包含指定中文的行?

python如何刪除包含指定中文的行?

#!/usr/bin/env?大蟒

#編碼=utf-8

def?read_del_list(路徑):

del_list?=?列表()

用什麽?打開(路徑,w’)?作為?文件句柄:

為了什麽?劃?在?文件句柄:

del_list.append(row.strip())

回歸?del_list

def?filte_file(from_file,to_file,?del_list):

用什麽?打開(from_file)?作為?文件句柄來源:

用什麽?打開(到文件)?作為?文件句柄至:

為了什麽?劃?在?文件句柄來源:

如果?不是嗎?any(關鍵字?在?劃?為了什麽?關鍵詞?在?del_list):

文件句柄寫入(行)

如果?__name__?==?__main__ ':

del_list?=?Read _ del _ list(r " del _ list . txt ")#讀取過濾規則。

filte_file(r"source.txt "," output.txt ",Del_list)#過濾文件