python操作word简单案例
直接看代码吧
import docx
##测试操作word
file=docx.Document() #创建内存中的word文档对象
file.add_paragraph("窗前明月光") #写入若干段落
file.add_paragraph("疑是地上霜")
file.add_paragraph("举头望明月")
p = file.add_paragraph("低头思故乡")
p.add...
2020-08-10 浏览(6230)
python操作word设置字体
设置字体
from docx.shared import Pt
file=docx.Document() #创建内存中的word文档对象
#设置字体样式(字体大小与字体样式)
mystyle = file.styles["Header"]
font = mystyle.font
font.size = Pt(12.5)
font.name = '宋体'
head.paragraphs[0].style = mystyle
其中字号与数字的...
2020-08-07 浏览(13964)
python 如何拼接一个双引号
利用转义字符即可,直接看代码
head=file.sections[0].header
Knowledge = quest_item['Knowledge']
head.paragraphs[0].text="\""+Knowledge+"\""+"嘿嘿嘿"
如果是中文问号是可以直接拼接的
"“"+Knowledge+"”"
2020-08-07 浏览(6922)
python for循环 下标
使用 enumerate 函数 可以返回下标
for inx, val in enumerate(['aaa', 'bbb']):
print(inx)
print(val)
for index,grandson in enumerate(child['PointList']):
print(index)
2020-08-06 浏览(8996)
python 使用pip命令无效,提示pip无效
python 使用pip命令无效,提示pip无效首先要确保你安装了pip,其次如果你没有配置环境变量什么的,需要在pip所在目录才能执行一般是在python目录下面的Scripts里边的
2020-08-06 浏览(10733)
python html编码解码
使用方法:html.escape(s)与html.unescape即可
import html
s="<div>jsdlfjsl</div>"
#html编码
b=html.escape(s)
print(b)
#htmlj解码
c=html.unescape(b)
print(c)
2020-08-06 浏览(7551)
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2026TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256
50010702506256
欢迎加群交流技术