《Python Cookbook v3.0.0》Chapter4 迭代器、生成器

感谢:
https://github.com/yidao620c/python3-cookbook
如有侵权,请联系我整改。

本文章节会严格按照原书(以便和原书对照,章节标题可能会略有修改),内容会有增删。

4.1 手动遍历迭代器

>>> items
[1, 2, 3]
>>> it=iter(items)
>>> it
<list_iterator object at 0x0000024B94D25408>
>>> next(it)
1
>>> next(it)
2
>>> next(it)
3
>>> next(it)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
StopIteration
>>> it=iter(items)
>>> next(it)
1
>>> print(*it)
2 3
>>> print(*it)

《Python Cookbook v3.0.0》Chapter4 迭代器、生成器

上一篇:Spring事务传播行为


下一篇:SpringBoot - HandlerInterceptor 中 @Autowired 为空