导入包
import pdfplumber
函数说明
函数 | 说明 |
extract_text() | 读取文字 |
extract_words() | |
extract_table() | 读取表格(列表) |
extract_tables() | 读取表格 |
读取pdf指定页面内容
with pdfplumber.open('C:/Users/Administrator/Desktop/期末/0操作系统/操作系统习题1.pdf') as pdf:
first_page = pdf.pages[0] # 第一页
print(first_page.extract_text())
读取所有页面内容
with pdfplumber.open('C:/Users/Administrator/Desktop/期末/0操作系统/操作系统习题1.pdf') as pdf:
for page in pdf.pages:
print(page.extract_text())
读取表格
参考:
https://www.bilibili.com/video/BV15E411g7py?p=2