We must first know what is iterative objects (objects can be used for cycles) Iterable:
A class: list, tuple, dict, set, str
Type II: generator, comprising a generator and a band of yield generatoe function
And not only act on the generator for, may also be next () function call to continue to the next and returns a value, next () returns the object constantly at a value function may be referred iterator: Iterator
Iterator objects are generators, but list, dict, str is Iterable, but not Iterator, should list, dict, str like Iterable Iterator may be used to convert ITER () function
next () usage:
Next (Iterator [, default])
Iterator - iterables
default - Alternatively, to return to the default values set in the absence of the next element, if not set, and no next element StopIteration exception is triggered.
List_ = >>> [1,2,3,4,5]
>>> IT = ITER (list_)
>>> Next (IT, '-. 1')
. 1
>>> Next (IT, '-. 1')
2
>>> Next (IT, '-. 1')
. 3
>>> Next (IT, '-. 1')
. 4
>>> Next (IT, '-. 1')
. 5
>>> Next (IT, '-. 1 ')
' -1 '
---------------------
author: A wave _ _
source: CSDN
original: https: //blog.csdn.net/li1615882553/ article / details / 79360172
copyright: This article is a blogger original article, reproduced, please attach Bowen link!