Python office编程:word和PowerPoint

本文介绍了如何使用Python的python-docx和python-pptx库来操作Word和PowerPoint文件。内容包括新建、保存文档,添加文本、标题、图片,设置字体样式,创建和编辑表格,以及批量更新PowerPoint文件。
摘要由CSDN通过智能技术生成

安装python-dock

From docx import Document

打开、新建word文档

新建文档:document=Document()

Document.save(‘filename.docx’)

添加文本:text=document.add_paragraph(‘content of the paragraph’)

更改项目符号:text.style=’stylename’

添加标题:document.add_heading(‘head-name’)

添加图片:document.add_picture(‘path of the picture’)

字体设置:

设置加粗:text.run.font.bold=True

设置字号:text.run.font.size=pt(sizeNumber)

设置字体颜色:text.run.font.color=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值