Last active
October 2, 2017 01:52
-
-
Save SpikeXy/892ea00a597060649299966b9151c8ef to your computer and use it in GitHub Desktop.
Iterator #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Iterator是惰性序列,因此通过list()函数让它把整个序列都计算出来并返回一个list | |
# list、dict、str等数据类型不是Iterator ,需要用iter()函数转换一下;可作用于for循环的对象都是Iterable类型;可作用于next()函数的对象都是Iterator类型; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> isinstance(iter([]), Iterator) | |
True | |
>>> isinstance(iter('abc'), Iterator) | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment