美文网首页
[python3]获取pptx演示文稿的“当前主题名称”

[python3]获取pptx演示文稿的“当前主题名称”

作者: fushall | 来源:发表于2017-12-08 23:47 被阅读0次

首先    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'))

相关文章

网友评论

      本文标题:[python3]获取pptx演示文稿的“当前主题名称”

      本文链接:https://www.haomeiwen.com/subject/naoyixtx.html