我正在尝试从剪贴板获取图像,并且想将该图像添加到 python-pptx 中。我不想将图像保存在磁盘中。我试过这个:
from pptx import Presentation
from PIL import ImageGrab,Image
from pptx.util import Inches
im = ImageGrab.grabclipboard()
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
left = top = Inches(1)
pic = slide.shapes.add_picture(im, left, top)
prs.save('PPT.pptx')
但是得到这个错误
File "C:\Python27\lib\site-packages\PIL\Image.py", line 627, in __getattr__
raise AttributeError(name)
AttributeError: read
这有什么问题?