【问题标题】:Python - Save A PDF file into DiskPython - 将 PDF 文件保存到磁盘
【发布时间】:2019-10-30 17:32:12
【问题描述】:

我有下面的代码,它在内存中创建了一个pdf 文件。

 pdf = pytesseract.image_to_pdf_or_hocr(self.main_window.filename, extension='pdf')

我想将该 pdf 文件保存在磁盘中以便查看。我将如何在 python 中做到这一点?

【问题讨论】:

标签: python python-3.x python-2.7 pdf


【解决方案1】:

如果type(pdf)<class 'bytes'> 类型,那么你可以这样做:

with open('yourfile.pdf', 'wb') as f:
    f.write(pdf)

【讨论】:

    猜你喜欢
    • 2011-12-25
    • 1970-01-01
    • 2016-07-22
    • 2013-12-19
    • 2010-09-23
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 2021-11-03
    相关资源
    最近更新 更多