我一直在编写代码来批量旋转文件夹内的 pdf 文件,但我找不到迭代和更改旋转文件的目标文件夹的方法,我的目的是将新文件以相同的名称保存在另一个文件夹,谢谢
import PyPDF2
from os import listdir
di = "C:\z_PruebPy\pdf"
archs = []
listarch = []
loc = r"C:/z_PruebPy/pdf/"
for x in listdir(di):
archs.append(loc+x)
for arch in listarch:
pdf_in = open(arch, 'rb')
pdf_reader = PyPDF2.PdfFileReader(pdf_in)
pdf_writer = PyPDF2.PdfFileWriter()
for pagenum in range(pdf_reader.numPages):
page = pdf_reader.getPage(pagenum)
page.rotateClockwise(270)
pdf_writer.addPage(page)
pdf_out = open(arch, 'wb') #????????
pdf_writer.write(pdf_out)
pdf_out.close()
pdf_in.close()