我在用Image. open(Path),函数时(这里的path是一张图片的路径,我用path代替了),出现了下面这些问题,各位大佬帮我看看,这个该怎么解决啊
AttributeError: 'list' object has no attribute 'seek'
AttributeError: 'list' object has no attribute 'read'
关于Python中的Image. open函数的使用出现的问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- 辉煌仪奇 2021-10-26 11:27关注
猜测你的代码如下
path定义成了一个listfrom 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))
运行成功通过
有帮助请采纳,有问题继续交流,你的采纳是对我回答的最大的肯定和动力
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用
悬赏问题
- ¥60 求一个简单的网页(标签-安全|关键词-上传)
- ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
- ¥15 基于卷积神经网络的声纹识别
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
- ¥100 为什么这个恒流源电路不能恒流?
- ¥15 有偿求跨组件数据流路径图
- ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
- ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
- ¥15 CSAPPattacklab
- ¥15 一直显示正在等待HID—ISP