【发布时间】:2021-12-28 18:02:41
【问题描述】:
我收到错误“引发 UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.bytesio object at>' 在以下代码中:
import io
from PIL import Image
file = io.BytesIO(str.encode('D:/Downloads/imagens/0b4d4db99a7b8ecba24909d277556de8.png'))
img1=Image.open(file)
img1.show()
还有很多其他类似的问题,但似乎都不是同一个问题。如果我去掉'str.encode',错误会变成“TypeError:需要一个类似字节的对象,而不是'str'”
【问题讨论】:
标签: python image io encode bytesio