sg1*_*994 13 python pdf text-extraction python-2.7
我如何在python中阅读pdf? 我知道将其转换为文本的一种方法,但我想直接从pdf中阅读内容.
任何人都可以解释python中哪个模块最适合pdf提取
小智 24
你可以使用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)
Run Code Online (Sandbox Code Playgroud)
请遵循此文档http://pythonhosted.org/PyPDF2/
您可以在python中使用textract模块
文字练习
安装
pip install textract
Run Code Online (Sandbox Code Playgroud)
阅读PDF
import textract
text = textract.process('path/to/pdf/file', method='pdfminer')
Run Code Online (Sandbox Code Playgroud)
详细信息