标签:
import re p=re.compile("gmail|aol|yahoo") f = open("test.txt",‘r+‘) lines = [line for line in f.readlines() if p.search(line) is None] f.seek(0) f.truncate(0) f.writelines(lines) f.close()
Python 删除文件特定字符的行
原文地址:http://www.cnblogs.com/wood9291/p/5106832.html