P29 - 在PPT中写入图片和表格 - 图1 P29 - 在PPT中写入图片和表格 - 图2 P29 - 在PPT中写入图片和表格 - 图3 P29 - 在PPT中写入图片和表格 - 图4

你好,我是UP:法学院毕业的Python程序员兆锋(点击查看🏆近期的付费答疑记录)
如有学习问题,欢迎加入学习群和我交流❤交流群

下面是本讲课程的视频、代码和配套文档:

主要内容

关于PPT这个主题,我们的美女老师还专门录了一个专题视频,请移步:

pip install python-pptx

from pptx import Presentation from pptx.util import Inches,Pt

ppt = Presentation() slide = ppt.slides.add_slide(ppt.slide_layouts[1])# 在PPT中插入一个幻灯片

left = Inches(1)

top = Inches(1)

width = Inches(2)

height = Inches(2)

#

img = slide.shapes.add_picture(‘img.jpg’,left,top,width,height)

rows = 2 cols = 2 left = Inches(1) top = Inches(1) width = Inches(4) height = Inches(4)

table = slide.shapes.add_table(rows,cols,left,top,width,height).table table.columns[0].width = Inches(1) table.columns[1].width = Inches(3) table.cell(0,0).text = ‘00’ table.cell(0,1).text = ‘01’ table.cell(1,0).text = ‘10’ table.cell(1,1).text = ‘11’ #二进制的11,代表十进制的多少?

ppt.save(‘text.pptx’)

```

配套文档

img.jpgtext.pptx

拓展内容

提问与答疑

提供以下3种交流方式:

  • 有任何问题,请加入Python学习群,和我交流~❤交流群
  • 也期待加我好友,我们深入沟通,我的微信:hdylw1024,请务必注明来意,否则很难通过。
  • 或者你也可以直接在本文档的留言板留言,和大家一起讨论~