小编Min*_*rva的帖子

使用Python获取pptx文件幻灯片的标题

我正在尝试使用 Python 获取幻灯片文件的每张幻灯片的标题。我在 Python 中使用 Presentation 包,但找不到任何指定标题的内容。我有这段代码可以返回powerpoint文件的内容。但我需要指定标题。

from pptx import Presentation

prs = Presentation("pp.pptx")

# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []

for slide in prs.slides:
    for shape in slide.shapes:
        if not shape.has_text_frame:
            continue
        for paragraph in shape.text_frame.paragraphs:
            for run in paragraph.runs:
                text_runs.append(run.text)
Run Code Online (Sandbox Code Playgroud)

python powerpoint python-pptx

5
推荐指数
1
解决办法
4322
查看次数

标签 统计

powerpoint ×1

python ×1

python-pptx ×1