ITPub博客

首页 > > > 请问这段代码为什么出错?

请问这段代码为什么出错?

作者:gamebus 时间:2019-08-07 10:37:12 0 删除 编辑
class number(object):
    value = 0
    def __next__(self):
        self.value += 1
        if self.value >10:
            raise StopIteration
        return self.value*self.value
pow = number()
for i in pow:
    print(i)


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4687/viewspace-3148653/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 请求大佬解答!
请登录后发表评论 登录
全部评论

注册时间:2019-07-10

  • 博文量
    155
  • 访问量
    13190