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/公开课/文档/第05次公开课-算法入门系列1-周而复始/code/example06.py
Views: 729
1
import re
2
3
import PyPDF2
4
5
with open('Python_Tricks_encrypted.pdf', 'rb') as pdf_file_stream:
6
reader = PyPDF2.PdfFileReader(pdf_file_stream)
7
with open('dictionary.txt', 'r') as txt_file_stream:
8
file_iter = iter(lambda: txt_file_stream.readline(), '')
9
for word in file_iter:
10
word = re.sub(r'\s', '', word)
11
if reader.decrypt(word):
12
print(word)
13
break
14
15
16