向指定段落添加内容

>>> c=Document(r'F:\word练习\指定段落.docx')
>>> c
<docx.document.Document object at 0x00000203B8F3C240>
>>> len(c.paragraphs)
5
>>> w=c.paragraphs[1]
>>> w
<docx.text.paragraph.Paragraph object at 0x00000203B8F30E80>
>>> w.insert_paragraph_before('这是我的第二段')
<docx.text.paragraph.Paragraph object at 0x00000203B8F30C40>
>>> c.save(r'F:\word练习\段落定位.docx')  

 

posted @ 2020-07-02 00:15  马蹄哒哒  阅读(227)  评论(0编辑  收藏  举报