AttributeError: 'tuple' object has no attribute 'type'
时间: 2023-08-03 18:07:09 浏览: 112
这个错误是因为你在代码中将一个numpy数组转换成了一个tuple类型,而tuple类型没有type属性。\[2\]在你的代码中,a = tuple(a)将a转换成了tuple类型,导致后续的type(a.shape)和a.shape都会报错。所以你需要确保你的数据类型是正确的。另外,关于你提到的extra_fb1是一个变量而不是方法的问题,可能是因为你在定义类方法时没有正确地传入self参数。\[3\]在类方法中,self是默认传入的,并且是在第一个位置,所以你需要将self参数放在第一个位置,将其他参数放在后面。这样就可以正确地访问到self里面的实例属性了。解决方案是将类方法的传参形式改成def up_date(self, img, roi)。这样就可以避免AttributeError: 'tuple' object has no attribute 'type'错误的发生了。
#### 引用[.reference_title]
- *1* *3* [定义类,AttributeError: ‘tuple‘ object has no attribute ‘extra_fb1‘ 报错及解决方案](https://blog.csdn.net/weixin_44298361/article/details/113811836)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [AttributeError系列之:AttributeError: 'tuple' object has no attribute 'shape'](https://blog.csdn.net/qq_41368074/article/details/105738815)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]