python pdf 操作
「pdfplumber:」
pdfplumber庫(kù)按頁(yè)處理 pdf ,獲取頁(yè)面文字,提取表格等操作。
學(xué)習(xí)文檔:https://github.com/jsvine/pdfplumber
「pypdf2:」
PyPDF2 是一個(gè)純 Python PDF 庫(kù),可以讀取文檔信息(標(biāo)題,作者等)、寫入、分割、合并PDF文檔,它還可以對(duì)pdf文檔進(jìn)行添加水印、加密解密等。
官方文檔:https://pythonhosted.org/PyPDF2
import pdfplumber
filename = ""
# 提取pdf表格
with pdfplumber.open(filename) as pdf:
# page01 = pdf.pages[0] #指定頁(yè)碼
for page in pdf.pages:
text = page.extract_text()#提取文本
table1 = page.extract_table()#提取單個(gè)表格
table2 = page.extract_tables()#提取多個(gè)表格
print(text,table1,table2)
來(lái)源:Python操作PDF全總結(jié)|pdfplumber&PyPDF2 - 知乎 (zhihu.com)

浙公網(wǎng)安備 33010602011771號(hào)