CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day15/pdf2.py
Views: 729
1
"""
2
读取PDF文件
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-26
7
"""
8
9
from PyPDF2 import PdfFileReader
10
11
with open('./res/Python课程大纲.pdf', 'rb') as f:
12
reader = PdfFileReader(f, strict=False)
13
print(reader.numPages)
14
if reader.isEncrypted:
15
reader.decrypt('')
16
current_page = reader.getPage(5)
17
print(current_page)
18
print(current_page.extractText())
19
20