如何在python-pptx中更改文本颜色?

时间:2019-11-12 21:52:02

标签: python powerpoint python-pptx

当前这是我的代码:

from pptx import Presentation
from pptx.util import Pt

f = open(r'template.pptx', 'rb')
prs = Presentation(f)
f.close()

slide = prs.slides.add_slide(prs.slide_masters[0].slide_layouts[1])

title = slide.placeholders[10]
title.text = "REPORT"

prs.save('test.pptx')

如何将“报告”标题文本设置为黄色和粗体?

1 个答案:

答案 0 :(得分:0)

使用title.font访问字体属性:

from pptx.dml.color import RGBColor # add this import to the top of the file

title.font.bold = True
title.font.color.rgb = RGBColor(0xFF, 0xFF, 0x00)