我正在尝试使用 python-docx 模块将样式应用于文档中的段落。我可以写新的文本,但我不能对以前写的段落应用不同的风格。
这是一个例子:
x = docx.Document('Sample.docx')
x
Out[81]: <docx.api.Document at 0x121cebed0>
x.paragraphs[2].style
Out[82]: 'Normal'
x.paragraphs[2].style = 'Title'
x.paragraphs[2].style
Out[84]: 'Normal'
我无法从文档中判断这是否应该工作。似乎表明段落样式是可写的,但文档中没有此用例的示例。
请让我知道这是我的问题,还是该功能尚未实现。