>>> 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‘)
原文:https://www.cnblogs.com/luckiness/p/13222484.html