pip install PyPDF2
import os
import PyPDF2
objFile = open('./js.pdf', 'rb') #打开文件
objPdfReader = PyPDF2.PdfReader(objFile) #打开pdf
nPages = objPdfReader.pages #获取总页数
for nPageIndex in range(len(nPages)):
objPage = objPdfReader.pages[nPageIndex] #获取某页
strContent = objPage.extract_text()
print(strContent) #打印内容
objFile.close() #关闭