I. iterators
Definition: Performs a repetition based on the last result to achieve a more optimal
An iterative object: An object that has a _iter_ method under a normal object.
Advantages of Iterative objects:
1. Provides a unified (independent of index) iterative approach
2. The iterator itself, which saves memory more than other data types
Disadvantages of iterators:
1. One-time, can only go backward, can not be returned, the index value is flexible
2. The iterator itself, which saves memory more than other data types
Two. Generator
Features: Special iterators that contain yield key inside the function
Yield Features:
1. Make the result of the function an iterator
2. The Save function pauses the state of the runtime and continues the next execution
Yield vs. return comparison:
Same: function with return value
Different: Ruturn can only return one value at a time, and yield returns multiple values
Python path-iterators