将有效的html输入转换为docx
html2docx的Python项目详细描述
html2docx
html2docx将有效的html输入转换为docx输出。项目已分发 在麻省理工学院的执照下。
安装
要安装,请使用pip:
$ pip install html2docx
用法
fromhtml2docximporthtml2docxwithopen("my.html")asfp:html=fp.read()# html2docx() returns an io.BytesIO() object. The HTML must be valid.buf=html2docx(html,title="My Document")withopen("my.docx","wb")asfp:fp.write(buf.getvalue())
测试
要运行测试套件,请使用tox:
$ tox