天天看點

Align your Paragraph via Python-docx

When you try to align your paragraph with the

WD_PARAGRAPH_ALIGNMENT

from docx.enum.text, you may like to set the

yourparagraph.alignment

as

WD_PARAGRAPH_ALIGNMENT.JUSTIFY

or *.LEFT, *.RIGHT, or even *.DISTRIBUTED.

Be careful to separate your run with a new paragraph as

yourdocument.add_paragraph().

Otherwise, the document will take the run you are setting as in the SAME paragraph even if separated with the `enter's as

'\n'.