4
votes

In Python is there a easy way to read a word document line by line. I would like to preserve the formatting while reading the line and copy to other doc after modifying some text.

I can see there is only paragraph reading but no line reading available in docx library.

1

1 Answers

6
votes

Try this:-

import docx
doc = docx.Document('your file')
for i in doc.paragraphs:
    print(i.text)