码迷,mamicode.com
首页 > 其他好文 > 详细

单独设置首页的页眉页脚

时间:2020-07-12 12:19:36      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:对齐   imp   word   different   diff   col   练习   footer   red   

from  docx import  Document
from  docx.shared  import  Pt
from  docx.enum.text  import  WD_ALIGN_PARAGRAPH  #导入对齐库
文件=Document(rE:\word练习\页眉页脚.docx)
第一节=文件.sections[0]
第一节.different_first_page_header_footer=True  #设置首页不同
首页对象=第一节.first_page_header
页眉=首页对象.paragraphs[0].add_run(这是页眉)
页眉.font.size=Pt(12)
首页对象.paragraphs[0].alignment=WD_ALIGN_PARAGRAPH.CENTER
首页对象=第一节.first_page_footer
页脚=首页对象.paragraphs[0].add_run(这是页脚)

文件.save(rE:\word练习\首页不同.docx)

 

单独设置首页的页眉页脚

标签:对齐   imp   word   different   diff   col   练习   footer   red   

原文地址:https://www.cnblogs.com/luckiness/p/13287655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!