I am trying to remove all the lines where my regex matches (regex just searching for any row In which it has Yahoo!). 'c: \\ temp \\ script \\ remove.txt', 'w', encoding = "utf8") I get the following error: Tracebacks (most recent call final): line 170, sub returned _compile (pattern, flags) .sub (repl, string, count) TypeError: expected string or buffer If you want to modify the original file, use the import reile inputfile = open (
fileinput module:
importin fileinput .input (r'C: \ temp \ lip If not re.search (r '\ byahoo \ b', line): print line,
No comments:
Post a Comment