【发布时间】:2022-08-16 16:50:00
【问题描述】:
是的,我知道存在很多关于这个问题的问题,但我无法让它们中的任何一个起作用。
我有 python 3.7 和 python-docx 0.8.11。 我尝试了很多解决方案,包括this one
from docx import Document, enum
document = Document()
mystyle = document.styles.add_style(\'mystyle\', enum.style.WD_STYLE_TYPE.CHARACTER)
run = document.add_paragraph().add_run(text)
run.style = mystyle
font = run.font
font.rtl = True
document.save(\'test.docx\')
还
from docx import Document, enum
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
doc = Document()
rtlstyle = doc.styles.add_style(\'rtl\', enum.style.WD_STYLE_TYPE.PARAGRAPH)
rtlstyle.font.rtl = True
p = doc.add_paragraph(text)
p.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
p.style = rtlstyle
doc.save(\'test.docx\')
到目前为止没有任何效果
-
i couldn\'t make any of them work怎么样?错误?不是rtl?提供的两种解决方案有什么区别?预期与实际 -
没有错误它只是从左到右写
-
我可以看到两者之间没有区别,只是在其中一种解决方案中对齐是向右的
标签: python python-3.7 right-to-left python-docx