read pdf with python

纯净搜索 为您找到 本页 3 条,用时 5.72 秒(数据源:360)

AI 回答 由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 使用`PyPDF2`库读取PDF文件。
2. 使用`fitz`库(PyMuPDF)读取PDF文件。
3. 使用`pdfplumber`库读取PDF文件。

示例代码(使用`PyPDF2`):

import PyPDF2

with open('example.pdf', 'rb') as file:
reader = PyPDF2.PdfFileReader(file)
print(reader.numPages) # 打印页数
print(reader.getPage(0).extractText()) # 提取第一页文本