# Use win32com package or docx package
# we use docx here
import win32com
import docx
from docx import Document
# 0. setting
WorkPath = 'D:/Script/DRM/'
File = 'DRM.docx'
FilePath=WorkPath+File
# 1.
def MatchStrList(StrChecked,StrKeyword):
LenResult=min(len(StrChecked),len(StrKeyword))
for i in range(min(len(StrChecked),len(StrKeyword))):
LenResult=LenResult*len(re.findall(StrKeyword[i],StrChecked[i]))
#should not contain space in StrKeyword cause the regular expression only pick up \s as space
#if one of Strlist is null, return 0
#if one of index is not match also return 0
return LenResult
def ReadDocxFile(FilePath):
try:
DocxFile = docx.Document(FilePath)
except IOexception as e:
return e
DRM={}
Layers={}
for p in DocxFile.paragraphs:
if ((len(p.text)>0)& (MatchStrList([p.text],['Manual&
Read DRM info from docx
最新推荐文章于 2021-10-21 15:03:13 发布