从powerpoint中提取声音文件

2024-06-17 17:56:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Python从powerpoint中提取声音文件。这是我写的:

from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE

file = open(filepath , 'rb') 
prs = Presentation(file)

for slide in prs.slides:
    for shape in slide.shapes:
        if shape.shape_type == MSO_SHAPE_TYPE.MEDIA:
            print('Found one')

但即使每张幻灯片上都有一个mp3文件,它也找不到任何东西,所以我打印了shape.shape\u类型的每个形状对象,奇怪的是没有GraphicFrame对象,只有图片、文本和自动形状

我怎样才能找到并提取它们


Tags: infromimportfortypepresentationfile形状