创建与修改文档Python-docx.zip

Python DocX目前是Python OpenXML的一部分,你可以用它打开Word 2007及以后的文档,而用它保存的文档可以在Microsoft Office 2007/2010, Microsoft Mac Office 2008, Google Docs, OpenOffice.org 3, and Apple iWork 08中打开。示例:from docx import Document from docx.shared import Inches document = Document() document.add_heading('Document Title', 0) p = document.add_paragraph('A plain paragraph having some ') p.add_run('bold').bold = True p.add_run(' and some ') p.add_run('italic.').italic = True document.add_heading('Heading, level 1', level=1) document.add_paragraph('Intense quote', style='IntenseQuote') document.add_paragraph( 'first item in unordered list', style='ListBullet' ) document.add_paragraph( 'first item in ordered list', style='ListNumber' ) document.add_picture('monty-truth.png', width=Inches(1.25)) table = document.add_table(rows=1, cols=3) hdr_cells = table.rows[0].cells hdr_cells[0].text = 'Qty' hdr_cells[1].text = 'Id' hdr_cells[2].text = 'Desc' for item in recordset: row_cells = table.add_row().cells row_cells[0].text = str(item.qty) row_cells[1].text = str(item.id) row_cells[2].text = item.desc document.add_page_break() document.save('demo.docx')效果图 标签:Python






- 1
- 2
- 3
- 4
- 5
- 6
- 115

















- 粉丝: 438
- 资源: 1万+

我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
已下载
下载帮助

python生成word,python-docx-template.zip
Python项目开发实战入门(实用性极强、方向全) 源码+文档.zip
python+docx+csv+文档模版自动生成报告.zip
基于Python实现Excel数据处理自动化生成Word文档(含索引目录 分页).zip
关于python中zip()展开的分析.docx
python3.doc转docx.zip 全注释
基于python3的手写数字识别代码.zip
Python快速入门培训ppt+面试题精选.zip
python-docs-samples, 在 cloud.google.com 上,使用的代码示例.zip
python_auto_doc.zip
