效果
代码
import pptx
# 新建ppt
ppt = pptx.Presentation()
# 所有的版式
layouts = ppt.slide_layouts
# 一张幻灯片
slide = ppt.slides.add_slide(layouts[1])
# 占位符
placeholders = slide.shapes.placeholders
print(placeholders)
print(len(placeholders))
# 占位符添加内容
placeholders[0].text = '这是标题'
placeholders[1].text = '这是正文内容\n第二行'
# 保存
ppt.save('myppt.pptx')