【发布时间】:2018-01-29 09:49:22
【问题描述】:
如何在 python 中阅读 pdf? 我知道一种将其转换为文本的方法,但我想直接从 pdf 中读取内容。
谁能解释一下python中的哪个模块最适合pdf提取
【问题讨论】:
标签: python python-2.7 pdf text-extraction
如何在 python 中阅读 pdf? 我知道一种将其转换为文本的方法,但我想直接从 pdf 中读取内容。
谁能解释一下python中的哪个模块最适合pdf提取
【问题讨论】:
标签: python python-2.7 pdf text-extraction
你可以使用 PyPDF2 包
#install pyDF2
pip install PyPDF2
# importing all the required modules
import PyPDF2
# creating an object
file = open('example.pdf', 'rb')
# creating a pdf reader object
fileReader = PyPDF2.PdfFileReader(file)
# print the number of pages in pdf file
print(fileReader.numPages)
【讨论】:
试试 PyPDF2。
【讨论】:
你可以在python中使用texttract模块
提取
用于安装
pip install textract
用于阅读 pdf
import textract
text = textract.process('path/to/pdf/file', method='pdfminer')
详情Textract
【讨论】: