如何检测Python docx中列表的样式(项目符号或编号)?

问题描述 投票:0回答:1

我需要阅读Docx文档并检测列表类型。 段落样式中没有列表类型的信息。 我通过

检测列表
if "<w:numId" in paragraph._p.xml:
    pass#this is list 

但我不知道如何获取列表的类型。也许在编号中有一些信息? 例如:

...
from docx.oxml import numbering

for paragraoh in document.paragraphs:
    if "<w:numId" in paragraph._p.xml:
        if numbering.style == "Numbering":
            pass#this is numbering 
        else:
            pass#this is bullet

为了阅读 Docx,我使用 python3 的 docx 库 如何获取列表的类型?

python xml list python-docx
1个回答
0
投票

如果有人回复请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.