【发布时间】:2017-06-18 03:49:52
【问题描述】:
我正在尝试使用 python 库 python-docx 在 MS Word 文件中编写文本。 我已经浏览了 python-docx 的字体颜色on this link 的文档,并在我的代码中应用了相同的内容,但到目前为止还没有成功。
这是我的代码:
from docx import Document
from docx.shared import RGBColor
document = Document()
run = document.add_paragraph('some text').add_run()
font = run.font
font.color.rgb = RGBColor(0x42, 0x24, 0xE9)
p=document.add_paragraph('aaa')
document.save('demo1.docx')
word文件'demo.docx'中的文字只是黑色。
我无法解决这个问题,我们将不胜感激。
【问题讨论】:
标签: python python-docx