Python如何把多个PDF文件合并代码实例
作者:conpi 时间:2021-03-27 00:31:15
这篇文章主要介绍了Python如何把多个PDF文件合并,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
代码如下
from PyPDF2 import PdfFileMerger
import os
files = os.listdir()#列出目录中的所有文件
merger = PdfFileMerger()
for file in files: #从所有文件中选出pdf文件合并
if file[-4:] == ".pdf":
merger.append(open(pdf, 'rb'))
with open('newfile.pdf', 'wb') as fout: #输出文件为newfile.pdf
merger.write(fout)
来源:https://www.cnblogs.com/conpi/p/12297763.html
标签:Python,PDF,合并
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js常用排序实现代码
2023-08-30 08:50:24
去掉CSS赘余代码,CSS可以更简洁
2008-11-05 13:07:00
用Python实现数据筛选与匹配实例
2023-01-13 15:31:42
![](https://img.aspxhome.com/file/2023/1/112411_0s.jpg)
手把手教你在Python里使用ChatGPT
2023-11-10 02:55:58
![](https://img.aspxhome.com/file/2023/9/75339_0s.jpg)
python将人民币转换大写的脚本代码
2021-03-05 17:36:23
Symfony控制层深入详解
2023-11-14 20:43:33
![](https://img.aspxhome.com/file/2023/6/92806_0s.png)
实际应用:MySQL5存储过程编写
2008-11-11 12:25:00
python制作花瓣网美女图片爬虫
2023-05-20 01:51:55
Python基于smtplib模块发送邮件代码实例
2022-09-18 11:07:49
图文详解Python中最神秘的一个魔法函数
2022-03-25 05:44:24
![](https://img.aspxhome.com/file/2023/7/104937_0s.jpg)
python递归计算N!的方法
2021-11-11 21:11:31
学习ASP.NET八天入门:第五天
2007-08-07 13:43:00
利用Python Matlab绘制曲线图的简单实例
2021-05-16 07:21:38
![](https://img.aspxhome.com/file/2023/4/78494_0s.png)
Sql server数据库优化
2010-04-06 19:17:00
python数据处理详情
2021-05-08 12:53:12
![](https://img.aspxhome.com/file/2023/6/112436_0s.png)
浅谈python中对于json写入txt文件的编码问题
2022-01-28 05:08:58
python pycurl验证basic和digest认证的方法
2022-12-17 23:01:15
Python深度学习实战PyQt5布局管理项目示例详解
2023-03-11 08:47:37
![](https://img.aspxhome.com/file/2023/9/87519_0s.png)
Python自动采集微信联系人的实现示例
2023-09-08 07:28:03
![](https://img.aspxhome.com/file/2023/2/117442_0s.jpg)
Python 之 Json序列化嵌套类方式
2021-05-25 18:11:44
![](https://img.aspxhome.com/file/2023/9/107119_0s.jpg)