【发布时间】:2021-09-08 00:05:22
【问题描述】:
我目前正在使用 python docx 库生成一个 word 文件。
我创建了多个包含文本和变量的表格。
当行中有变量时,我将它们标记为:
我需要将分隔符 var 的颜色更改为红色以突出显示它。
我认为关于文本颜色的唯一方法是:
p=document.add_paragraph()
wp = p.add_run('I want this sentence colored red with fontsize=22')
wp.font.color.rgb = RGBColor(255,0,0)
但它适用于所有段落,而不是特定部分。
【问题讨论】:
标签: python colors fonts python-docx