python python-pptx对pptx文件读取示例,以下是如何使用pptx.Presentation()的代码示例。
python-pptx安装:
pip install python-pptx
官网文档:
https://python-pptx.readthedocs.io/en/latest/index.html
代码:
from pptx import Presentation # 打开pptx文件 prs=Presentation(r'C:\Users\admin\Desktop\test\演示文稿1.pptx') # 遍历每一页的幻灯片 for slide in prs.slides: # 遍历每一个幻灯片的形状 for shape in slide.shapes: # 判断该形状是否是一个文字框架 if not shape.has_text_frame: continue for paragraph in shape.text_frame.paragraphs: # 拼接文字 print(''.join(run.text for run in paragraph.runs))
参考文章:
https://www.programcreek.com/python/example/105890/pptx.Presentation
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。