首页
视频
资源
登录
风清月
愿你出走半生,归来仍是少年
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
mvc
9篇
c#面试题
1篇
爬虫
1篇
Redis
1篇
NET
37篇
JS相关
2篇
Oracle
1篇
随笔
30篇
学点小英语
9篇
Vue.js
3篇
jquery
2篇
Sqlerver
7篇
前端
53篇
ps
1篇
net core
39篇
更多
架构
9篇
rpc
1篇
EF
6篇
mui
8篇
微服务
8篇
微信
1篇
.net
5篇
svn
1篇
人工智能
6篇
nginx
4篇
docker
14篇
git
4篇
c++
3篇
linux
11篇
uniapp
7篇
k8s
23篇
python
3篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术
原
python 操作word,设置页眉,页脚。设置页眉方向
4050
人阅读
2022/8/4 22:07
总访问:
1659567
评论:
0
收藏:
0
手机
分类:
python
### 引入 可能有很多不需要的 重点是docx相关的引入 ``` from CzPylib import Request from fake_useragent import UserAgent import requests import re import json import time import os import html import docx from docx.shared import Pt from docx.oxml.ns import qn from docx.enum.text import WD_PARAGRAPH_ALIGNMENT #设置对其方式 ``` ###设置页眉与方向 ``` #处理页眉,处理页眉 head=file.sections[0].header Knowledge = quest_item['Knowledge'] head.paragraphs[0].text="\""+Knowledge+"\""+"知识点评估题" head.paragraphs[0].alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT#靠右 ``` 页脚的设置基本是一样的,看看这样的 ``` footer = document.sections[0].footer # 获取第一个节的页脚 paragraph = footer.paragraphs[0] # 获取页脚的第一个段落 paragraph.add_run('')#添加内容 paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER#居中 ```
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}