# encoding=utf8 #-*-coding:utf-8 -*- # pip install aspose.slides -i https://pypi.tuna.tsinghua.edu.cn/simple import aspose.slides as slides from pptx import Presentation #导入PPT库 import win32com.client, sys from glob import glob # 打開第一張PPT with slides.Presentation("1.pptx") as pres1: # 打開第二個PPT with slides.Presentation("2.pptx") as pres2: # 循環播放幻燈片 for slide in pres2.slides: # 克隆幻燈片 pres1.slides.add_clone(slide) # 保存合併的 PPT pres1.save("combined.pptx", slides.export.SaveFormat.PPTX) for i in range(3,50): with slides.Presentation("combined.pptx") as pres1: # 打開第二個PPT with slides.Presentation("%s.pptx"%str(i)) as pres2: # 循環播放幻燈片 for slide in pres2.slides: # 克隆幻燈片 pres1.slides.add_clone(slide) # 保存合併的 PPT pres1.save("combined.pptx", slides.export.SaveFormat.PPTX) print("保存第%s个"%str(i)) # def join_ppt(ppt_folder,new_PPT): # Application = win32com.client.Dispatch("PowerPoint.Application") # Application.Visible = True # # Create new presentation # new_ppt = Application.Presentations.Add() # # files = glob(ppt_folder) # for f in files: # # Open and read page numbers # exit_ppt = Application.Presentations.Open(f) # page_num = exit_ppt.Slides.Count # exit_ppt.Close() # num = new_ppt.Slides.InsertFromFile(f, new_ppt.Slides.Count, 1, page_num) # # Presentation.Save(new_PPT) # Application.Quit() # if __name__ == '__main__': # ppt_folder = r"D:\PycharmProjects\xiaoxiaomu\制作PPT\49\ppt" # new_PPT = "nnn.pptx" # # print(sys.argv[1]) # join_ppt(ppt_folder,new_PPT) # # 打開第一張PPT # with slides.Presentation("1.pptx") as pres1: # # 打開第二個PPT # with slides.Presentation("2.pptx") as pres2: # # 循環播放幻燈片 # for slide in pres2.slides: # # 克隆幻燈片 # pres1.slides.add_clone(slide) # # # 保存合併的 PPT # pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
分类:
Python制作PPT
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构