Article From:https://www.cnblogs.com/realsoong/p/9906630.html

Python 3 Function Classification

Iterator

Definition: We call such objects iterative, i.e. suitable as an objective (parameter) of a function or structure that expects continuous terms from something until the end.

Common iterators:

for Sentence:

>>>#Measure some strings:
... words = ['cat', 'window', 'defenestrate']
>>> for w in words:
...     print(w, len(w))
...
cat 3
window 6
defenestrate 12   

list()Function – Create lists

>>> list(range(5))
[0, 1, 2, 3, 4]

range() Function-Generated Link List

>>> for i in range(5):
...     print(i)
...
0
1
2
3
4
>>> for i in range(5):
...     print(i)
...
0
1
2
3
4

Leave a Reply

Your email address will not be published. Required fields are marked *