有勇气的牛排博客

python 操作pdf

有勇气的牛排 233 Python 2023-05-18 20:47:02

导入包

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())

读取表格

image.png

参考:
https://www.bilibili.com/video/BV15E411g7py?p=2


留言

专栏
文章
加入群聊