可以使用 PyPDF2 库来打开 PDF 文件。首先需要安装 PyPDF2,可以使用 pip 安装:pip install pypdf2。然后可以使用以下代码打开一个 PDF 文件:
import PyPDF2# Open the PDF file
with open('example.pdf', 'rb') as file:
reader = PyPDF2.PdfFileReader(file)
print(reader.numPages)
可以使用 PyPDF2 库来打开 PDF 文件。首先需要安装 PyPDF2,可以使用 pip 安装:pip install pypdf2。然后可以使用以下代码打开一个 PDF 文件:
import PyPDF2# Open the PDF file
with open('example.pdf', 'rb') as file:
reader = PyPDF2.PdfFileReader(file)
print(reader.numPages)