【在python-docx中是否有可能将段落垂直和水平对齐?】

2024-04-26 17:24:29 发布

您现在位置:Python中文网/ 问答频道 /正文

{x我想知道的是,如果你想在一个文档的中间对齐一个文本,我就可以把它垂直对齐。在


Tags: 文档文本
1条回答
网友
1楼 · 发布于 2024-04-26 17:24:29

目前在库中无法执行此操作。但是,我发现,通过对齐现有文档中的文本,然后用pythondocx打开它,您可以简单地编辑文本,并且它将保留其格式。在

enter image description here

from docx import document

document = Document('template.docx')
# This just grabs the first paragraph, code assumes you've already applied formatting.
document.paragraphs[0].text = "Example Text"
document.save('output.docx')

相关问题 更多 >