代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。