python - AttributeError: 'list' 对象没有属性 'shape' 问题
问题描述
我正在尝试获取数组(文件)中的值,并且我想将它们保存在一个目录中,所以我正在使用 plt.imsave(os.path.join())
并且我遇到了一个问题:
代码 :
for i in tab:
plt.imsave(os.path.join(target_directory,str(i)), tab)
我收到这个错误AttributeError: 'list' object has no attribute 'shape'
有人有想法吗?谢谢
解决方案
tab
可能不是您的图像,因为您正在对其进行迭代。
事实上,tab
很可能是一个列表,而 Matplotlibimsave
期望它是一个 numpy 数组(它有一个shape
属性)。
我的猜测是你不打算传递tab
给imsave
其他东西。
推荐阅读
- excel - 尝试 Web 抓取时出现 VBA 运行时 91 错误
- xml - 如何使用 Unmarshal 解析 XML
- c# - 使用子句搜索错误包括:实体框架
- react-native - React Native - 获取 JSON 返回不同的 URL
- python - 确定两个数组是否是彼此的旋转版本
- google-analytics - 在 Google Analytics 中创建受众时未找到事件操作
- python - Huggin 面对对话错误:错误:参数 --model:无效选择:'models/'(从 'openai-gpt'、'gpt2' 中选择)
- javascript - $(...).tooltip 不是一个函数 rails 6 webpack
- flutter - 数据持久化 - 如何持久化数据列表
- python - 从 python 中获取凭据