Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 pdf 文件中搜索一个单词或一行?
是否有一个现有的模块可以通过简洁来做到这一点?
先感谢您,
有一种叫做pyPDF 的东西。 它是一个Pure-Python构建为PDF toolkit.
Pure-Python
PDF toolkit.
您可以提取(使用extractText()方法)并使用以下代码对 pdf 文件执行搜索。
extractText()
pdf = pyPdf.PdfFileReader(file(path, "rb")) content = pdf.getPage(1).extractText()