Text-Replace in docx and save the changed file with python-docx

前端 未结 8 807
小鲜肉
小鲜肉 2021-01-02 07:04

I\'m trying to use the python-docx module to replace a word in a file and save the new file with the caveat that the new file must have exactly the same formatting as the ol

8条回答
  •  南方客
    南方客 (楼主)
    2021-01-02 07:55

    We can use python-docx to keep an image on docx. docx detect image as a paragraph. But for this paragraph the text is empty. So you can use like this. paragraphs = document.paragraphs for paragraph in paragraphs: if paragraph.text == '': continue

提交回复
热议问题