依赖包 PyPDF2
代码如下:
if __name__ == '__main__':
output = PdfFileWriter()
for i in xrange(9):
pdf = PdfFileReader(open(str(i) + '.pdf', 'rb'), strict=False)
number = pdf.getNumPages()
for j in xrange(1, number - 1):
output.addPage(pdf.getPage(j))
print str(i) + '.pdf merged'
output.write(open('result.pdf', 'wb'))