import mammoth
f = open("D:\filename.docx", 'rb')
document = mammoth.convert_to_html(f)
Run Code Online (Sandbox Code Playgroud)
我在运行此代码时无法获取 .html 文件,请帮助我获取它,当我转换为 .html 文件时,我没有将图像插入到 .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()
Run Code Online (Sandbox Code Playgroud)
小智 2
我建议你尝试下面的代码
import mammoth
with open("document.docx", "rb") as docx_file:
result = mammoth.convert_to_html(docx_file)
html = result.value
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9838 次 |
| 最近记录: |