import pdfplumber
import pandas as pd
#打开pdf文件
with pdfplumber.open(filePath) as pdf:
first_page = pdf.pages[0]
text = first_page.extract_text()
print(text)
#读取第二页表格数据
second_page = pdf.pages[1]
#在第二页提取表格
table = second_page.extract_tables()
for t in table:
df = pd.DataFrame(t[1:],columns=t[0])
#打印
print(df)