我正在尝试使用 python 中的 pypandoc 包将 docx 文件转换为 html 文件。这是我的代码(删除了文件路径) -
import pypandoc
filename = <filepath>
output=pypandoc.convert(filename,to='html',extra_args=['--extract-media=<foldername>'])
filename=os.path.splitext(filename)[0]
filename="{0}.html".format(filename)
with open(filename,'w') as f:
if type(output) is not str:
output=output.encode("utf-8")
f.write(output)
它不会插入 docx 文件中存在的图像,并且文本的颜色全部更改为黑白。我应该怎么做才能将所有图像放在 html 文件中并保持所有文本格式不变?