gpt4 book ai didi

python - 从 PPTx 文件 (powerpoint) 中提取演示者注释

转载 作者:行者123 更新时间:2023-12-02 19:16:24 50 4
gpt4 key购买 nike

是否有 python 或 php 解决方案可以让我从 powerpoint 文件中的每张幻灯片中获取演示者注释?

谢谢

最佳答案

您可以使用 python-pptx

pip 安装 python-pptx

您可以执行以下操作来提取演讲者备注:

import collections 
import collections.abc
from pptx import Presentation

file = 'path/to/presentation.pptx'

ppt=Presentation(file)

notes = []

for page, slide in enumerate(ppt.slides):
# this is the notes that doesn't appear on the ppt slide,
# but really the 'presenter' note.
textNote = slide.notes_slide.notes_text_frame.text
notes.append((page,textNote))

print(notes)

notes 列表将包含不同页面上的所有注释。

如果要提取幻灯片上的文字内容,需要这样做:

for page, slide in enumerate(ppt.slides):
temp = []
for shape in slide.shapes:
# this will extract all text in text boxes on the slide.
if shape.has_text_frame and shape.text.strip():
temp.append(shape.text)
notes.append((page,temp))

关于python - 从 PPTx 文件 (powerpoint) 中提取演示者注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63659972/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com