应该是一个字符串吧。只不过是二进制的字符串。可以先转为一个StringIO的对象,它就象一个file对象,然后使用PIL的open就可以打开了。如:def thumbnail_string(buf, size=(50, 50)): f = StringIO.StringIO(buf) image = Image.open(f) if image.mode not in ('L', 'RGB'): image = image.convert('RGB') image = image.resize(size, Image.ANTIALIAS) o = StringIO.StringIO() image.save(o, "JPEG") return o.getvalue()复制代码