我正在尝试使用 Python 获取 powerpoint 文件的每张幻灯片的标题。我正在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)
这是我的解决方案:
from pptx import Presentation
filename = path_of_pptx
prs = Presentation(filename)
for slide in prs.slides:
title = slide.shapes.title.text
print(title)
Input:
Output:
Hello, World!
Hello, World2!
Hello, World3!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)