generator object has no attribute next
时间: 2023-09-03 19:10:26 浏览: 236
在Python 3.x中,生成器对象(generator object)不再有next()方法,而是使用__next__()方法来获取下一个元素。所以在你的代码中,应该使用g.__next__()来获取生成器的下一个元素。这个错误提示是因为你在使用g.next()时,生成器对象没有next()属性,导致AttributeError异常的出现。如果你想要通过next()方法访问生成器对象,可以使用内置的next()函数,即next(g)。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [python 2.x 错误 ‘generator’ object has no attribute ‘_F_hawk189_新浪博客](https://blog.csdn.net/F_hawk189/article/details/109652603)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Python错误:AttributeError: 'generator' object has no attribute 'next'解决办法](https://blog.csdn.net/gaifuxi9518/article/details/81059938)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [mybatis generator 自动生成 dao mapping object](https://download.csdn.net/download/knight_black_bob/9773699)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文