标签:walk filename pen nbsp 参考 ade enum folders nump
import os,PyPDF2 os.chdir(‘D:\\My Documents‘) for folderName, subfolders, filenames in os.walk(‘D:\\My Documents‘): for file in filenames: if file.endswith(‘.pdf‘): pdfFile = open(file, ‘rb‘) pdfReader = PyPDF2.PdfFileReader(pdfFile) pdfWriter = PyPDF2.PdfFileWriter() for pageNum in range(pdfReader.numPages): pdfWriter.addPage(pdfReader.getPage(pageNum)) pdfWriter.encrypt(‘123456‘) resultPdf = open(file +‘encrypted.pdf‘, ‘wb‘) pdfWriter.write(resultPdf) resultPdf.close()
python编程快速上手之第13章实践项目参考答案(13.6.1)
标签:walk filename pen nbsp 参考 ade enum folders nump
原文地址:http://www.cnblogs.com/flying-wyf/p/6875880.html