Friday, March 30, 2018

Python docx Tutorial

Don't install docx, install python-docx

$ pip install python-docx

>>> from docx import Document

Then, a basic one is :

doc = Document.('docName.docx')
for para in doc.paragraphs :
   print para.text

How should you know that you have paragraphs and text for each para? You can use the TAB key when you've typed "doc." (without the quotes, of course).

No comments: