'generator' object has no attribute 'isin'
时间: 2023-08-05 11:03:23 浏览: 167
浅谈keras通过model.fit_generator训练模型(节省内存)
引用\[2\]中的代码中出现了一个错误:'generator' object has no attribute 'next'。这个错误是因为在Python 3中,生成器对象的next()方法已经被__next__()方法取代了。所以,正确的调用方式应该是使用__next__()方法来获取生成器对象的下一个元素。修改代码如下所示:
```python
# 定义生成器函数
def liebiao():
for x in range(10):
yield x
# 函数调用
g = liebiao()
# 打印元素
print(g.__next__())
```
这样就可以正确地获取生成器对象的下一个元素了。
#### 引用[.reference_title]
- *1* [【无标题】generator‘ object has no attribute ‘skipped](https://blog.csdn.net/weixin_42796704/article/details/127907095)[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* [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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Python之os模块的学习(十九)](https://blog.csdn.net/yyang3121/article/details/80533928)[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 ]
阅读全文