""" author:少校 create Time:2025/2/26 15:32 越努力越幸运 """ from PyPDF2 import PdfWriter,PdfReader # 1.删除MySQL必知必会文件的封面 reader1 = PdfReader("files/MySQL必知必会.pdf") pdf1 = PdfWriter() for x in reader1.pages[1:]: pdf1.add_page(x) pdf1.write("files/data1.pdf") # 2.将学员手册的封面替换成MySQL的封面 reader2 = PdfReader("files/千锋培训班学员手册.pdf") pdf2 = PdfWriter() pdf2.add_page(reader1.pages[0]) for x in reader1.pages[1:]: pdf2.add_page(x) pdf2.write("files/data2.pdf") # 3.将两个pdf文件合并成一个文件 pdf3 = PdfWriter() for x in reader1.pages: pdf3.add_page(x) for x in reader2.pages: pdf3.add_page(x) pdf2.write("files/data3.pdf")
02.PDF页的操作练习
本节638字2025-02-27 19:14:34