bestehen
V2EX  ›  Python

Python 中的去除水印代码

By bestehen at 2018 年 7 月 31 日 · 4005 次点击
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 啥意思?
1 条回复
talen666
   1
talen666  
   2018 年 7 月 31 日
点进 LZ 个人页面,这问题。。。
PS:你先把 Python 学一遍再来问问题吧
推荐学习书目
› 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
© 2026 V2EX · 26ms · 3.9.8.5