1 Star 1 Fork 2

大鱼的胡须/doc-docx-file-read

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
readdoc.py 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
大鱼的胡须 提交于 2019-10-30 18:40 . initialization
import docx
import recognition
# document = docx.Document('demo.docx')
class SearchIdAndPhoneNumber:
#初始化文档
document = docx.Document()
def __init__(self,str):
self.document = docx.Document(str)
#查找段落
def search_paragraphs(self):
for para in self.document.paragraphs:
if recognition.check_id_card(para.text):
results = recognition.check_id_card(para.text)
for result in results:
print(result.group())
# print( '<Match: %r, groups=%r>' % (result.group(), result.groups()))
# print(result.string)
if recognition.verify_mobile(para.text):
results = recognition.verify_mobile(para.text)
for result in results:
print(result.group())
#查找表
def search_tables(self):
for table in self.document.tables:
for row in table.rows:
for cell in row.cells:
if recognition.verify_mobile(cell.text):
results = recognition.verify_mobile(cell.text)
for result in results:
print(result.group())
if recognition.check_id_card(cell.text):
results = recognition.check_id_card(cell.text)
for result in results:
print(result.group())
def search(self):
self.search_paragraphs()
self.search_tables()
# for i in range(len(document.paragraphs)):
# print("第"+str(i)+"段的内容是:"+document.paragraphs[i].text)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Novocaine/doc-docx-file-read.git
git@gitee.com:Novocaine/doc-docx-file-read.git
Novocaine
doc-docx-file-read
doc-docx-file-read
master

搜索帮助