python 将word转化为html

pip install pydocx

from pydocx import PyDocX
html = PyDocX.to_html("test.docx")
f = open("test.html", 'w', encoding="utf-8")
f.write(html)
f.close()

通过网页上传word文档,只接收docx



windows下,将doc转为docx
pip3 install pypiwin32

from win32com import client
word = client.Dispatch("Word.Application")
doc = word.Documents.Open("D:\\.doc") //绝对路径 doc文件
doc.SaveAs("D:\
\.docx",16) //保存的docx 文件,绝对路径
doc.Close()
word.Quit()

你可能感兴趣的:(python 将word转化为html)