#复制粘贴并运行如下代码即可
# -*- coding: utf-8 -*-
from pptx import Presentation
prs = Presentation()
bullet_slide_layout = prs.slide_layouts[1]
slide = prs.slides.add_slide(bullet_slide_layout)
shapes = slide.shapes
title_shape = shapes.title
body_shape = shapes.placeholders[1]
title_shape.text = ‘Adding a Bullet Slide,#title_shape.text’
tf = body_shape.text_frame
tf.text = ‘Find the bullet slide layout,#tf = body_shape.text_frame’
p = tf.add_paragraph()
p.text = ‘Use _TextFrame.text for first bullet’
p.level = 1
p = tf.add_paragraph()
p.text = ‘Use _TextFrame.add_paragraph() for subsequent bullets’
p.level = 2
prs.save(‘test002.pptx’)
源代码截图
”’ 运行后生成ppt文件如下图 ”’