hello#!/usr/bin/env python3# -*- coding: utf-8 -*-from pptx import Presentation
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Hello, World!"subtitle.text = "python-pptx 可以轻松制作powerpoint!"prs.save('test.pptx')
图片.png
Bulletfrom 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'tf = body_shape.text_frame
tf.text = 'Find the bullet slide layout'p = tf.add_paragraph()
p.text = 'Use _TextFrame.text for first bullet'p.level = 1p = tf.add_paragraph()
p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets'p.level = 2prs.save('test.pptx')