发布时间:2019-09-18 07:27:52编辑:auto阅读(1904)
安装python-docx
pip install python-dox
如果python2安装后不能使用(找不到包),建议直接使用python3,安装代码如下
pip3 install python-dox
from docx import Document
from docx.shared import Pt
# 简单的打开word,输入数据,关闭word
document = Document()
# 向word里增加段落
document.add_paragraph('hello')
document.save('test.docx')
# 在一个段落中增加文字
document = Document()
paragraph = document.add_paragraph('Normal text, ')
# 增加文字
paragraph.add_run('add text')
# 设置word字体大小
style = document.styles['Normal']
font = style.font
font.size = Pt(10)
document.save('test.docx')
上一篇: python3 centos下安装tki
下一篇: Python安装zlib模块
48150
46866
37784
35089
29623
26272
25211
20248
19889
18368
6021°
6719°
6204°
6183°
7296°
6136°
6254°
6727°
6703°
8082°