我试图用pythondocx将一些文本写入docx文件。我想从右到左对齐文本,我已经为它添加了一个样式,但这不起作用。在
代码如下:
from docx.enum.style import WD_STYLE_TYPE
missingwords= Document()
styles = missingwords.styles
style = missingwords.styles.add_style('rtl', WD_STYLE_TYPE.PARAGRAPH)
style.font.rtl = True
paragraph =missingwords.add_paragraph("Hello world",style='rtl')
我还没来得及玩docx(我主要使用Excel python模块),但是based on the documentation here看起来你修改了style的错误属性。字体属性per this definition of the rtl property只会修改added run(通过
myparagraph.add_run("Hello World", style = "rtl")
)。据我所知,您要查找的代码是:然后你可以像以前一样继续添加段落
^{pr2}$再说一遍,把文档删掉,让我知道这是否有效。在
相关问题 更多 >
编程相关推荐