How to extract text from an existing docx file using python-docx

后端 未结 7 1112
不思量自难忘°
不思量自难忘° 2020-11-27 15:59

I\'m trying to use python-docx module (pip install python-docx) but it seems to be very confusing as in github repo test sample they are using

7条回答
  •  渐次进展
    2020-11-27 16:37

    you can try this

    import docx
    
    def getText(filename):
        doc = docx.Document(filename)
        fullText = []
        for para in doc.paragraphs:
            fullText.append(para.text)
        return '\n'.join(fullText)
    

提交回复
热议问题