bl = "hahahah" with open("/etc/hosts","r",encoding="utf-8") as f: lines = f.readlines() with open("/etc/hosts","w",encoding="utf-8") as f_w: for line in lines: if bl in line: continue f_w.write(line)
bl = "hahahah" with open("/etc/hosts","r",encoding="utf-8") as f: lines = f.readlines() with open("/etc/hosts","w",encoding="utf-8") as f_w: for line in lines: if bl in line: continue f_w.write(line)