提取pdf文档表格

 1 import   pdfplumber
 2 
 3 pdf=pdfplumber.open(',,,,,,,.pdf')
 4 
 5 first_page=pdf.pages[0]
 6 
 7 print(first_page.extract_text())    #打印第一页内容
 8 
 9  
10 
11 #提取其中的表格
12 
13 first_page.extract_table()    #提取这一页的第一个表格
14 
15 first_page.extract_tables()     #提取这一页内的所有表格
16 
17 #提取表格时设置表格参数
18 
19 first_page.extract_table(
20 
21 table_settings={'
22 
23        vertical_strategy':'text',
24 
25        'horizontal_strategy':'text'
26 
27       }
28 
29         )
30 
31  
32 
33 if    not   ''.join(  [  str(i)   for  i in  first_page.extract_text( )   ]  )   == '' :    #这行不为空则继续执行以下操作
34 
35   ''.join( [ str(item)  if  item   else  ''  for  item  in    i[:3]  )
原文地址:https://www.cnblogs.com/luckiness/p/13080440.html