python使用python-pptx删除ppt某页实例
作者:xiaotuzigaga 时间:2022-10-23 16:19:59
公司安排了个任务,爬取ppt资源,我爬取后打开ppt发现,最后一页是站点的宣传,需要删除。
仔细阅读了python-pptx的api和国内的教程,发现没有人写了关于删除ppt中某页的功能,所以科学上网去google上搜了一下,发现作者已经实现了,下来贴上如何删除
from pptx import Presentation
# 读取ppt
prs = Presentation('./temp.pptx)
# 查看一共几页
slides = prs.slides
number_pages = len(slides)
print(number_pages)
# 删除最后一页
rId = prs.slides._sldIdLst[-1].rId
prs.part.drop_rel(rId)
del prs.slides._sldIdLst[-1]
# 保存新的ppt
prs.save('./new.pptx')
来源:https://blog.csdn.net/xiaotuzigaga/article/details/88655516
标签:python,pptx,ppt
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
基于Tensorflow的MNIST手写数字识别分类
2023-12-01 11:35:18
![](https://img.aspxhome.com/file/2023/5/103295_0s.jpg)
python爬取指定微信公众号文章
2021-03-29 02:34:39
PHPStudy hosts文件可能不存在或被阻止打开及同步hosts失败问题
2023-06-08 10:29:10
![](https://img.aspxhome.com/file/2023/4/55494_0s.jpg)
MySQL存储文本和图片的方法
2024-01-12 17:56:03
Python I/O与进程的详细讲解
2022-11-27 14:07:15
![](https://img.aspxhome.com/file/2023/4/133524_0s.png)
pytorch中的model=model.to(device)使用说明
2023-02-23 15:07:48
asp上传文件自动重命名方法
2007-08-24 09:46:00
python3中str(字符串)的使用教程
2021-07-19 00:28:47
Python实现的HMacMD5加密算法示例
2022-01-15 06:05:31
利用phpmyadmin设置mysql的权限方法
2023-11-24 02:12:46
![](https://img.aspxhome.com/file/2023/4/65714_0s.png)
MySQL数据库中设列的默认值为Now()的介绍
2009-03-06 17:40:00
PyInstaller如何打包依赖文件至目标程序目录
2021-05-31 12:08:12
![](https://img.aspxhome.com/file/2023/7/130817_0s.jpg)
Python高级编程之消息队列(Queue)与进程池(Pool)实例详解
2021-12-14 17:30:24
![](https://img.aspxhome.com/file/2023/6/107496_0s.png)
javascript demo 基本技巧
2024-04-29 13:24:45
在Python中使用poplib模块收取邮件的教程
2023-02-05 20:48:25
![](https://img.aspxhome.com/file/2023/0/107850_0s.png)
python 计算数组中每个数字出现多少次--“Bucket”桶的思想
2023-06-28 19:37:55
![](https://img.aspxhome.com/file/2023/7/68947_0s.png)
深入理解python try异常处理机制
2023-01-06 00:51:35
mac 安装python网络请求包requests方法
2023-08-05 09:01:41
![](https://img.aspxhome.com/file/2023/9/100769_0s.jpg)
Python中logging日志记录到文件及自动分割的操作代码
2022-09-08 12:33:33
![](https://img.aspxhome.com/file/2023/9/107989_0s.png)
请不要重复犯我在学习Python和Linux系统上的错误
2023-05-05 05:01:31
![](https://img.aspxhome.com/file/2023/5/71525_0s.png)