I have a .doc
file that contains text, I need to replace a particular phrase with another one in this document.
I tried using python-docx
but it doesn't support the .doc
format. I also tried using the normal string replace functionality but it's corrupting the doc file
with open("input.doc") as r:
text = r.read().replace("old text", "new text")
with open("output.doc", "w") as w:
w.write(text)
I can't change the extension of the file and I want to do it in python.