writer.writerows(list(new)) TypeError: 'float' object is not iterable
时间: 2024-04-23 13:28:35 浏览: 125
这个错误是由于在调用`writer.writerows(list(new))`时,`new`对象是一个浮点数,而浮点数是不可迭代的,所以会导致`TypeError: 'float' object is not iterable`错误。\[3\]
要解决这个问题,你需要确保`new`对象是一个可迭代的对象,例如一个列表或元组。你可以将浮点数包装在一个列表中,然后传递给`writer.writerows()`函数,如下所示:
```python
writer.writerows(\[new\])
```
这样就可以避免`TypeError`错误。
#### 引用[.reference_title]
- *1* [pytorch错误及解决方案](https://blog.csdn.net/NEUdeep/article/details/115724826)[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* *3* [《Python数据分析基础》学习记录003:照着书里的代码敲,报错TypeError:‘int’ object is not iterable,...](https://blog.csdn.net/Haoyu_xie/article/details/106662055)[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 ]
阅读全文