Python 官方文档:入门教程 => 点击学习
[目的] 使用python编辑Micorsoft Word 文档 [测试环境] OS: MS XP professional SP3 Win32 Python:2.6.6 [准备]
python setup.py install
[疑问]
结果展示
#coding=UTF-8 from docx import * def testmakedocument(): relationships = relationshiplist() document = newdocument() body = document.xpath('/w:document/w:body', namespaces=nsprefixes)[0] body.append(heading(u"文件和文件夹服务接口", 1)) body.append(paragraph(u'请求格式')) request_rows = [ ['Http method', 'url', u'说明'] , ['POST', 'http://www.163.com', 'B3'] ] body.append(table(request_rows)) body.append(paragraph(u'参数说明')) body.append(paragraph(u'相应内容')) body.append(paragraph(u'示例')) body.append(heading(u"上传文件", 1)) title = u'空间服务器接口说明文档' subject = u'空间服务器接口说明' creator = u'未名' keywords = ['alfresco', 'url', 'JSON'] coreprops = coreproperties(title=title, subject=subject, creator=creator, keywords=keywords) # Save our document savedocx(document, coreprops, appproperties(), contenttypes(), WEBsettings(), wordrelationships(relationships), u'空间服务器接口说明文档.docx') def testUnit(): testmakedocument() if __name__ == '__main__': testUnit()
[疑问]
--结束END--
本文标题: [Python] python-docx
本文链接: https://www.lsjlt.com/news/188145.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0