import pdfplumber import re def pdf_read(): pdf=pdfplumber.open('文件路徑'")#文件路徑,讀取文件 page0=pdf.pages[11] #指定頁數 tables=page0.extract_tables()#獲得該頁的表格 texts=page0.extract_text()#獲得text文本值
pdfplumber 缺省通過表格線來區分行和列,所以下列情況是無法提取出表格的:
* 你的表格是圖片,通過選擇可以確定是否圖片
* 你的表格不是用線來分隔,或者分隔不全,例如列用線,行沒線
這種情況下,你就需要嘗試:page0.extract_tables(table_settings={})