from  docx  import  Document
from  docx.shared  import  Cm
文件=Document(r'E:\word练习\页眉页脚.docx')
第一节=文件.sections[0]
print("上边距:",第一节.top_margin.cm)
print("下边距:",第一节.bottom_margin.cm)
print("左边距:",第一节.left_margin.cm)
print("右边距:",第一节.right_margin.cm)

#设置页面边距
第一节.top_margin=Cm(5)
第一节.bottom_margin=Cm(5)
第一节.left_margin=Cm(4)
第一节.right_margin=Cm(4)

文件.save(r'E:\word练习\设置页边距.docx')

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。