Beginner Python (eight)--iteration
Beginner Python, mainly finishing some of the learning points, this is an iteration.
#-*-coding:utf-8-*- fromCollectionsImportiterable" "' Iteration" "L= ['af','St',' at','Psst','Beta'] D= {1:'af', 2:'St', 3:' at', 4:'Psst', 5:'Beta'} S='HelloWorld' #Array forIteminchL:PrintItem#Dictionary forKeyinchD:PrintKey#The default is the key value, you want to take values, call the Itervalues () method forValueinchd.itervalues ():Printvalue#Key,value simultaneously take forKey,valueinchD.iteritems ():PrintKey,value#string forChinchS:PrintCH#determine if an iteration can be iterated#whether the string iteratesPrintisinstance (s,iterable)#whether an array can be iteratedPrintisinstance (l,iterable)#whether the dictionary can iteratePrintisinstance (d,iterable)#whether decimals can be iteratedPrintIsinstance (11.2, iterable)#whether integers are iteratedPrintIsinstance (1, iterable)#whether Boolean values can be iteratedPrintisinstance (false,iterable)#whether set can iteratePrintIsinstance (Set ([]), iterable)#whether a tuple can iteratePrintIsinstance (), iterable)#Enumerate forIndex,valueinchEnumerate (L):PrintIndex,value
Beginner Python (eight)--iteration