from docx import Document from docx.enum.text import WD_ALIGN_PARAGRAPH document = Document('test.docx') paragraph = document.add_paragraph('123') paragraph.paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER document.save('test.docx')
调整左缩进0.3英寸:
1 2 3 4 5
document = Document('test.docx') paragraph = document.add_paragraph('this is test for left_indent with inches') paragraph_format = paragraph.paragraph_format paragraph_format.left_indent = Inches(0.3) document.save('test.docx')