python给word添加换行换页符

import docx
doc2=docx.Document()
doc2.add_paragraph('this is on the first page')
#换页只需要把docx.enum.text.WD_BREAK.PAGE作为唯一的参数传递给add_break
#如果是换行的话就不需要使用docx.enum.text.WD_BREAK.PAGE参数
doc2.paragraphs[0].runs[0].add_break(docx.enum.text.WD_BREAK.PAGE)
doc2.add_paragraph('this is on the seconed page')
doc2.save('example4.docx')

猜你喜欢

转载自www.cnblogs.com/shunguo/p/11399308.html