python修改word文档的域_python修改word文件(doc)页眉页脚
发布日期:2021-11-19 18:35:43
浏览次数:8
分类:技术文章
本文共 510 字,大约阅读时间需要 1 分钟。
#coding=utf8
import os
import docx
nowpath='需要修改的文件的路径'
topath='另存到的路径'
os.chdir(nowpath)
for iin os.listdir('.'):
print(i)
if os.path.splitext(i)[1]== '.doc':
try:
file=docx.Document(i)
file.sections[0].header.paragraphs[0].text= '你要修改成的页眉'
file.sections[0].footer.paragraphs[0].text= '你要修改成的页脚'
file.save(os.path.join(topath,i))
except Exception as e:
print(e)
continue
遇见的错误:
file 'xxxx.doc' is not a Word file, content type is 'application/vnd.openxmlformats-officedocument.themeManager+xml'
不是word格式的文件不能转
转载地址:https://blog.csdn.net/weixin_39927214/article/details/110271797 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2024年04月10日 07时18分07秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
unity3D 音频播放
2019-04-27
xml中常用的转义符
2019-04-27
腾讯MSDK手Q微信授权登录
2019-04-27
腾讯MSDK for Unity
2019-04-27
关于MSDK的几个难点
2019-04-27
使用UnityEditor做工具
2019-04-27
Visual Studio我常用的快捷键
2019-04-27
写C# dll供Unity调用
2019-04-27
Linux制作run安装包
2019-04-27
一分钟学会C#解析XML
2019-04-27
unity AssetBundle的资源管理
2019-04-27
【转】Unity中HideInInspector和SerializeField一起使用
2019-04-27
单例模板类
2019-04-27
Unity与java相互调用
2019-04-27
android截屏代码
2019-04-27
unity NGUI图文混排
2019-04-27
Unity项目优化
2019-04-27
Unity3D Shader 入门
2019-04-27
eclipse识别不到真机设备问题的解决
2019-04-27
MSDK手Q邀请透传参数问题:url编解码与base64编解码
2019-04-27