python (iteration) Section XI.

 

By for ... intraversing ist, tuple, dict, string loop, we call this traversal iteration (Iteration).


 

(A), iterative

Code:

for S in  ' Hello crazy ' :
     Print (S, End = '  ' )

result:

Hello madman

 


(B) whether the object can be determined iteration the Iterable (iterables)

Code:

from collections import Iterable

Print (isinstance ( ' abc ' , Iterable))   # str whether iteration

Print (the isinstance ([. 1, 2,. 3], the Iterable))   # List whether the iteration

Print (the isinstance (123, the Iterable)) # whether the iteration may be an integer

result:

True
True
False

  



 

 

Guess you like

Origin www.cnblogs.com/abcd8833774477/p/11815518.html