请问:如何使用python模块的pptx,对pptx里面文本框的内容进行修改?如将:我是大明星改为我是小明星,和把大明星删去的操作。

img
修改为:
img
和删除文本变成下面:
img
请配详细解答,如各个函数,方法的作用,谢谢大家。


from pptx import Presentation

prs = Presentation('test1.pptx')
#获取所有的幻灯片    
for slide in prs.slides:    
        #获取所有的占位符(文本框)
    for shape in slide.shapes:   
        #判断是否有内容
        if shape.has_text_frame:   
            text_frame = shape.text_frame
               # 修改替换
            if '大明星' in text_frame.text:  
                text_frame.text='替换测试'  
            if '文本框' in text_frame.text:
                text_frame.text=''

prs.save('12.pptx')

img

这个用vsto来写很快。