How does __iter__ work?

前端 未结 5 1064
不知归路
不知归路 2021-02-04 02:17

Despite reading up on it, I still dont quite understand how __iter__ works. What would be a simple explaination?

I\'ve seen def__iter__(self): retu

5条回答
  •  既然无缘
    2021-02-04 02:56

    A class supporting the __iter__ method will return an iterator object instance: an object supporting the next() method. This object will be usuable in the statements "for" and "in".

提交回复
热议问题