使用Python保存剪贴板图片

2022-07-30 12:37:50

经常用WinShiftS截图,如果是用来发QQ、写Word还是挺方便的,但是保存下来就没那么方便了,想到写个脚本 |果然懒也是一种驱动力


首先要有Pillow包:pip install Pillow

import timeimport PIL.ImageGrabfrom ntimport systemtry:
    img=PIL.ImageGrab.grabclipboard()
    img.save(time.strftime("%Y.%m.%d_%H.%M.%S.png", time.localtime()),"png")
    system("color 27")except AttributeError:
    system("color 47")
time.sleep(0.5)

粘贴到一个.py文件,如果.py文件的默认打开方式是Python解释器,直接单击脚本就可保存截图

  • 作者:夏木゜
  • 原文链接:https://blog.csdn.net/m0_46628923/article/details/120631463
    更新时间:2022-07-30 12:37:50