我有一个文档
然后 我给你们写好了一个代码
from PyPDF2 import PdfReader, PdfWriterdef split_pdf(file_path, ranges, output_names):# Open the input PDF filewith open(file_path, 'rb') as pdf_file:reader = PdfReader(pdf_file)total_pages = len(reader.pages)if len(ranges) != len(output_names):raise ValueError("Number of ranges must match the number of output names.")for i, page_range in enumerate(ranges):writer = PdfWriter()start, end = page_range# Ensure the page range is within the total pagesif start < 1 or end > total_pages or start > end:raise ValueError(f"Invalid page range: {start}-{end}")for page_num in range(start - 1, end):wr