玩蛇网提供最新Python编程技术信息以及Python资源下载!

python save保存图片系统提示错误请帮忙分析python源码

很基本的操作,比如

import Image
im = Image.open('male.png')
im.save('test.png')

就能出错,报错信息是这样的:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1439, in save
save_handler(self, fp, filename)
File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 572, in _save
ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 481, in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 399, in _getencoder
return apply(encoder, (mode,) + args + extra)

但是

im.show()

是可以看到图片的。
搜了好久都没搜到类似的问题...

刚提问就搜到答案了!
参考:http://stackoverflow.com/questions/17451711/typeerror-when-resizing-an-image-with-pil-in-python/17451810#17451810

改变一下导入方式就能解决这个问题了

from PIL import Image

感谢万能的栈爆网!XD

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd19618.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年05月23日 - 11时04分24秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules