如何使用 python 将 .docx 文件转换为 html?

2024-05-07

import mammoth

f = open("D:\filename.docx", 'rb')
document = mammoth.convert_to_html(f)

当我运行此代码时,我无法获取 .html 文件,请帮助我获取它,当我转换为 .html 文件时,我没有将 word 文件中的图像插入到 .html 文件中,你能帮我解决一下吗将图像从 .docx 转换为 .html?


尝试这个:

import mammoth

f = open("path_to_file.docx", 'rb')
b = open('filename.html', 'wb')
document = mammoth.convert_to_html(f)
b.write(document.value.encode('utf8'))
f.close()
b.close()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 python 将 .docx 文件转换为 html? 的相关文章

随机推荐