当前位置:网站首页>TypeError: iter() returned non-iterator of type ‘xxx‘
TypeError: iter() returned non-iterator of type ‘xxx‘
2022-06-21 06:01:00 【Channing Lewis】
最近在读《Python高级编程》(Ziade著),看到里面的自我设计的迭代器:
自己写的:
class MyIter:
def __init__(self,step):
self.step=step
def __iter__(self):
return self
def next(self):
if self.step==0:
raise StopIteration
self.step-=1
return self.step
for i in MyIter(5):
print(i)
跑的时候报错:
TypeError: iter() returned non-iterator of type ‘xxx’
因为我用的是Python3,所以next应该是__next__,改了之后就正常了。
边栏推荐
- After the code is generated by the code generator, the copy is completed, and the module is not displayed on the web page
- Digital signal processing-07-dds IP application example
- 【MYSQL】MySQL的SQL语句执行流程
- Aurora8b10b IP usage-03-ip configuration application guide
- Leetcode 75 - 颜色分类 [Medium] 三种实现方法
- How to select a game server with high stability and good defense performance
- numpy. get_ include()
- 构建和保护小型网络考试
- [JVM] classloader
- 回答问题:你认为AGI应该采用什么思路?
猜你喜欢

contos7 安装svn服务端

利用burp进行爆破(普通爆破+验证码爆破)

模块 14 - 15:网络应用通信考试

构建和保护小型网络考试

Aurora8b10b IP usage-05-transceiver test application example

Module 14 - 15: network application communication test

Copy the code generated by the code generator to the idea. How to solve the error reported by the web address after running

Aurora8b10b IP usage-03-ip configuration application guide

C language course design (detailed explanation of clothing management system)

MSF内网渗透
随机推荐
Aurora8b10b IP usage-05-transceiver test application example
DDD 实践手册(4. Aggregate — 聚合)
How to select a game server with high stability and good defense performance
Asp. Net web API 2 Lesson 18 - working with entity relations in OData
You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server
Le premier caractère unique de la chaîne (4)
Aurora8B10B IP使用 -02- IP功能設計技巧
牛客-TOP101-BM26
leetcode 675. Cutting down trees for golf competitions - (day29)
Leetcode 75 - 颜色分类 [Medium] 三种实现方法
第一章:数据库系统概述(数据库期末复习)
【数据挖掘】期末复习 第二章
[data mining] final review Chapter 4
【【毕业季·进击的技术er】------老学长心得分享
Chapter 2: Data Model (final review of database)
sqli-labs26
Connection refused : no futher information : localhost/127.0.0.1:6379
判断一棵树是否为完全二叉树
tf.compat.v1.get_default_graph
xshell7远程连接服务器,挂起进程一直维持程序的运行