美文网首页
python-docx批量生成word文档方法1

python-docx批量生成word文档方法1

作者: Leo_23 | 来源:发表于2018-10-30 21:53 被阅读14次

    批量生成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)
    
    

    相关文章

      网友评论

          本文标题:python-docx批量生成word文档方法1

          本文链接:https://www.haomeiwen.com/subject/wmvntqtx.html