CodePudding user response:
The from docx import Document
Def delete_paragraph (com.lowagie.text.paragraph) :
P=com.lowagie.text.paragraph. _element
P.g etparent (). Remove (p)
P. _p=p. _element=None
# create a blank document, and set up the style
MyDocument=Document (' test1. Docx)
# set a blank style
For num, paragraphs in enumerate (myDocument. Paragraphs) :
If paragraphs. The text=="" :
Print (' first {} is a blank line section. The format (num))
# remove text paragraphs. The clear (), does not delete the paragraph, the run can also,
Delete_paragraph (paragraphs)
MyDocument. Save (' test2. Docx)
Online to find the answer, is like this
CodePudding user response:
Wrong delete the situation, the only figure in the line without words, has been deleted