2

i use the ImageGrab.grabclipboard(),it may get the none return.

    # 将表格中的数据进行图片化
    excel = win32.Dispatch('Excel.Application')
    wb = excel.Workbooks.Open(dst_file)
    ws = wb.WorkSheets('概览')

    ws.Range("A1:F10").CopyPicture()
    time.sleep(1)
    img = ImageGrab.grabclipboard()
    time.sleep(5)
    if isinstance(img, Image.Image):
        print("total.png size : %s, mode: %s" %(img.size,img.mode))
        img.save("total.png")
    elif img == None:
        print("clipboard  is empty")

it show the error: AttributeError: 'NoneType' object has no attribute 'save'

And then i google, and add sleep time ,but also failed

And now ,i am confirm that it cause by ImageGrab.grabclipboard(), pls help me to resolve this,thanks!

7lin
  • 21
  • 1

0 Answers0