Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python用户-从从从docx转换的html文档中检索脚注(docx2python不工作)_Python_Html_Regex_Xml_Docx - Fatal编程技术网

python用户-从从从docx转换的html文档中检索脚注(docx2python不工作)

python用户-从从从docx转换的html文档中检索脚注(docx2python不工作),python,html,regex,xml,docx,Python,Html,Regex,Xml,Docx,我需要一些帮助从python中的docx文档检索脚注,因为docx文件包含大量脚注 下面是我目前遇到问题的代码,因为docx2python无法读取超过一定数量的页面的word文档 from docx2python import docx2python docx_temp = docx2python(filepath) footnotes = docx_temp.footnotes footnotes = footnotes[0][0][0] footnotes = [i.replace("\

我需要一些帮助从python中的docx文档检索脚注,因为docx文件包含大量脚注

下面是我目前遇到问题的代码,因为docx2python无法读取超过一定数量的页面的word文档

from docx2python import docx2python


docx_temp = docx2python(filepath)
footnotes = docx_temp.footnotes
footnotes = footnotes[0][0][0]
footnotes = [i.replace("\t","") for i in footnotes]
因此,我尝试了下面的其他方法,但由于不熟悉XML,我无法确定代码是否正常工作,因此我陷入了困境:

import re
import mammoth


with open(filepath, 'rb') as file:
    html = mammoth.convert_to_html(file).value
    #html = re.sub('\"(.+?)\"', '"<em>\1</em>"', html)
    fnotes = re.findall('id="footnote-<number>" (.*?) ', html)
你们能告诉我如何正确地编写代码从docx/HTML文件中提取脚注吗。谢谢你的帮助

import re
import zipfile
import xml.etree.ElementTree
from docx2python import docx2python


docxfile = zipfile.ZipFile(open(filepath,'rb'))
xmlString = docxfile.read('word/footnotes.xml').decode('utf-8')
fn = docxfile.read('word/footnotes.xml')
xml.etree.ElementTree.parse(fn)