如何将.docx样式的映射导出到庞大的python并嵌入?

2024-06-26 04:36:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个.docx文档,我正试图将其转换为html。它有一些自定义样式。样式是否可以导出到mammoth或直接嵌入word文档(word ui)

我确实看到了一些关于使用python-docx将样式导出到mammothcomments的内容,但它们在细节上很浅显

下面是我使用docx访问文档中样式的代码

from docx import Document
from docx.enum.style import WD_STYLE_TYPE

document = Document("some.docx")

styles = document.styles

# Do you choose a style from styles and embed? 
mammoth.embed_style_map(docx_file, styles[0] )

有没有办法将这些样式导出到mammoth? 先谢谢你


Tags: from文档importuistylehtml样式embed