后浪云Python教程:python存储jpg图片出错解决方法

后浪云Python教程:python存储jpg图片出错解决方法插图

python的出错信息:

后浪云Python教程:python存储jpg图片出错解决方法插图1

解决方法:

安装pillow模块即可解决

pip install pillow

图片的打开与显示

from PIL import Image
img=Image.open('d:/dog.png')
img.show()

虽然使用的是Pillow,但它是由PIL fork而来,因此还是要从PIL中进行import. 使用open()函数来打开图片,使用show()函数来显示图片。

THE END