首先 pip install python-pptx
代码如下:
# coding: utf8
from pptx import Presentation
from pptx.oxml import parse_xml
from pptx.opc.constants import RELATIONSHIP_TYPE
pptx = Presentation('测试.pptx')
theme_part = pptx.part.part_related_by(RELATIONSHIP_TYPE.THEME)
xml_elements = parse_xml(theme_part.blob)
elements= xml_elements.xpath('/a:theme[@name]')
for ele in elements :
#输出可看见结果
print(ele.attrib.get('name'))