背景需要分析一批高层次人才简历数据
环境
python 3.6
pip install docx
案例代码
def parse():
path = "xx简历.docx"
doc = docx.Document(path)
dict_rel = doc.part._rels
for rel in dict_rel:
rel = dict_rel[rel]
if "image" in rel.target_ref: # 这里内容中会包含Image的信息
print(rel.target_ref) # media / image1.jpeg
img_name = re.findall("/(.*)", rel.target_ref)[0]
img_path = path.split(".")[0]+".jpeg"
with open(img_path, 'wb') as f:
f.write(rel.target_part.blob)
解析DOCX文件与提取图片信息
该博客介绍了一个Python代码示例,用于解析DOCX文档并提取其中的图片信息。通过`docx`库,代码能够访问文档的关系部分,识别包含`image`的引用,并保存图片到本地。此方法对于处理包含图片的Word文档自动化处理非常有用。
338

被折叠的 条评论
为什么被折叠?



