python-docx批量生成word文档方法1
程序员文章站
2022-04-18 18:48:08
...
批量生成word文档办法1
python-docx 0.8.7 documentation
pip install python-docx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "leo"
__time__ = "2018-10-30"
from docx import Document
from docx.shared import Pt
if __name__ == '__main__':
for i in range(1, 151):
input_doc = Document('INNOVATIONS 正嘜-CHINA.docx')
c = ' C/NO. %d C\n MADE IN CHINA' % i
run = input_doc.add_paragraph('').add_run(c)
run.bold = True
font = run.font
font.name = 'Times New Roman'
font.size = Pt(70)
name = "%d.docx" % i
input_doc.save(name)
转载于:https://www.jianshu.com/p/46e8e9057f1e
上一篇: 字节码