我在用Image. open(Path),函数时(这里的path是一张图片的路径,我用path代替了),出现了下面这些问题,各位大佬帮我看看,这个该怎么解决啊
AttributeError: 'list' object has no attribute 'seek'
AttributeError: 'list' object has no attribute 'read'
猜测你的代码如下
path定义成了一个list
from PIL import Image
Path=['./123.png']
print(Image. open(Path))
Traceback (most recent call last):
File "F:\project\Question\venv\lib\site-packages\PIL\Image.py", line 2972, in open
fp.seek(0)
AttributeError: 'list' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\project\Question\main.py", line 2607, in <module>
print(Image. open(Path))
File "F:\project\Question\venv\lib\site-packages\PIL\Image.py", line 2974, in open
fp = io.BytesIO(fp.read())
AttributeError: 'list' object has no attribute 'read'
修改如下即可,
from PIL import Image
Path=['./123.png']
for i in Path:
print(Image. open(i))
from PIL import Image
Path='./123.png'
print(Image. open(Path))
运行成功通过
有具体代码吗
题主的问题,貌似在Image. open之后的代码里,不贴代码,难以定位。