小编Max*_*der的帖子

是否有任何方法可以使用python-docx读取.docx文件包含自动编号

问题陈述:从.docx文件中提取包含自动编号的部分.

我尝试使用python-docx从.docx文件中提取文本,但它排除了自动编号.

from docx import Document

document = Document("wadali.docx")


def iter_items(paragraphs):
    for paragraph in document.paragraphs:
        if paragraph.style.name.startswith('Agt'):
            yield paragraph
        if paragraph.style.name.startswith('TOC'):
            yield paragraph
        if paragraph.style.name.startswith('Heading'):
            yield paragraph
        if paragraph.style.name.startswith('Title'):
            yield paragraph
        if paragraph.style.name.startswith('Heading'):
            yield paragraph
        if paragraph.style.name.startswith('Table Normal'):
            yield paragraph
        if paragraph.style.name.startswith('List'):
            yield paragraph


for item in iter_items(document.paragraphs):
    print item.text
Run Code Online (Sandbox Code Playgroud)

python docx python-docx

15
推荐指数
2
解决办法
1528
查看次数

调试时只需要特定的循环索引

MATLAB有一些方便的功能,有助于通过函数调用简化代码调试,如下所示:

  • "step" 执行一行而不显示函数体指令.
  • "step in" 如果可能,导航到相应的函数体.
  • "continue" 通常执行代码行直到下一个断点.

有没有办法(或黑客,因为我发现在调试工具中找不到任何选项)来加速循环迭代到所需的索引?手动迭代大于300x300的图像中的像素索引是荒谬的浪费时间.

比方说,我想在下面的循环迅速达到一个特定的指数,例如x=50y=90:

for x=leftxlimit:rightxlimit
    for y=topylimit:botylimit
        if (toplayers2(y,x) == 0)
            ...
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

debugging matlab loops

2
推荐指数
1
解决办法
54
查看次数

标签 统计

debugging ×1

docx ×1

loops ×1

matlab ×1

python ×1

python-docx ×1