import pdfplumber
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
path="C:/Users/MAIBENBEN/Desktop/郑州大学.pdf"
pdf = pdfplumber.open(path)
print('\n')
print('开始读取数据')
print('\n')
print(pdf.pages[1].extract_tables()[0][0])
ws.append(pdf.pages[1].extract_tables()[0][0])
for page in pdf.pages:
for table in page.extract_tables():
for row in table:
if "序号" not in row:
rowlist=str(row).replace("[","",).replace("]","").replace("'","").replace("\\n","").split(",")
print(rowlist)
ws.append(rowlist)
print('---------- 分割线 ----------')
pdf.close()
wb.save('郑州大学.xlsx')
print('\n')
print('写入excel成功')