V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bestehen
V2EX  ›  Python

Python 中的去除水印代码

  •  
  •   bestehen · 2018-07-31 11:19:58 +08:00 · 3073 次点击
    这是一个创建于 2102 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 啥意思?
    talen666
        1
    talen666  
       2018-07-31 16:59:46 +08:00
    点进 LZ 个人页面,这问题。。。
    PS:你先把 Python 学一遍再来问问题吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2082 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:50 · PVG 09:50 · LAX 18:50 · JFK 21:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.