energetic

import   pdfplumber

pdf=pdfplumber.open(\',,,,,,,.pdf\')

first_page=pdf.pages[0]

print(first_page.extract_text())    #打印第一页内容

 

#提取其中的表格

first_page.extract_table()    #提取这一页的第一个表格

first_page.extract_tables()     #提取这一页内的所有表格

#提取表格时设置表格参数

first_page.extract_table(

table_settings={\'

       vertical_strategy\':\'text\',

       \'horizontal_strategy\':\'text\'

      }

        )

 

if    not   \'\'.join(  [  str(i)   for  i in  first_page.extract_text( )   ]  )   == \'\' :    #这行不为空则继续执行以下操作

  \'\'.join( [ str(item)  if  item   else  \'\'  for  item  in    i[:3]  )

 

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-12-05
  • 2021-05-29
  • 2021-12-16
  • 2021-07-15
  • 2021-12-10
  • 2021-12-10
  • 2021-11-30
猜你喜欢
  • 2021-10-19
  • 2021-11-07
  • 2021-12-29
  • 2021-11-19
  • 2021-11-07
  • 2021-12-10
  • 2021-10-19
相关资源
相似解决方案