python读取PPT内容

tech2024-10-04  17

 

##作业 ##打开哔哩哔哩财报.pptx ##按照paragraph分段,转换为word文档 ##保存为哔哩哔哩财报.docx

问题:保存下来的无任何格式可言,杂乱无章,是需要待完善的地方

from pptx import Presentation from docx import Document doc=Document() prs=Presentation('Bilibili 2Q19 Investor Presentation-Final.pptx') ##print(type(prs))  #<class 'pptx.presentation.Presentation'> for slide in prs.slides:     for shape in slide.shapes:         if shape.has_text_frame:             text_frame=shape.text_frame             for paragraph in text_frame.paragraphs:                 doc.add_paragraph(paragraph.text) doc.save('Bilibili 2Q19 Investor Presentation-Final.docx')

 

最新回复(0)