python之从PPT提取文字到word

python之从PPT提取文字到word_第1张图片

python之从PPT提取文字到word_第2张图片

from docx import Document
from pptx import Presentation
wordfile=Document()
filepath=r'test.pptx'
pptx=Presentation(filepath)
for slide in pptx.slides:
    for shape in slide.shapes:
        if shape.has_text_frame:
            text_frame=shape.text_frame
            for paragraph in text_frame.paragraphs:
                wordfile.add_paragraph(paragraph.text)
save_path=r'test.docx'
wordfile.save(save_path)

python之从PPT提取文字到word_第3张图片

你可能感兴趣的:(python办公自动化,python,powerpoint,word)