First, generator
The data type that can be traversed by for is an iterative type, which can be iterated by next as an iterator. such as the list
The generator does not generate elements when it is not called. A new element is generated only by a call, such as a For loop, or next ().
Example
c= (i*2 for I in range) for I in C: print (i)
This is a generator.
Functions can be converted to generators by yield
def sal (max): n=0 while N<max: yield n n+=1
This is also a generator
Second, iterators
You can use next to get the current element and return to the current state
DEF sport: While True: project=yield Print ("Start%s Sport"%project) C1=sport () C2=sport ()
Iterators can emit a value by sending () to yield and return to the next state,
Concurrent effects can be achieved via send
Third, JSON
Serialization and deserialization of Json.dumps and Json.loads
JSON can only be used for relatively simple data types: Lists, dictionaries, these
Complex data, such as functions, must be serialized by means of pickle.
Serialization and deserialization of Pickle.dumps and Pickle.loads
Generator, iterator, JSON