parser = argparse.ArgumentParser()
parser.add_argument('input_pdf_path', metavar='PATH')
parser.add_argument('-o', '--output', metavar='out', type=argparse.FileType('wb'),
help='Output PDF file')
parser.add_argument('-s', '--skip', type=int, default=0,
help='Skip over the first n page(s).')
args = parser.parse_args()
logger = logging.getLogger(__name__)
logging.basicConfig(level='INFO', format='%(asctime)s - %(levelname)s - %(message)s')
directory = './temp/'
if not os.path.exists(directory):
os.makedirs(directory)
images_path = []
pdf = PdfFileReader(open(args.input_pdf_path, "rb"))
for i in range(0, pdf.getNumPages()):
logger.info("Processing page {}/{}".format(i + 1, pdf.getNumPages()))
images_path.append("./temp/{}.jpg".format(i))
process_page(pdf, i, i < args.skip)
logger.info('Writing to output PDF file')
args.output.write(img2pdf.convert(*list(map(img2pdf.input_images, images_path))))
logger.info('Done')
python 里面的*list 这里的* 是指针吗? 还有就是这的 args.output.write 啥意思?