python python-pptx对pptx文件读取示例
发布时间:2020-12-17 17:03:46 所属栏目:Python 来源:网络整理
导读: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#?打开p
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:UsersadminDesktoptest演示文稿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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |