Python the next day-loop

Source: Internet
Author: User

  Dictionary loops
#dic={' name ': ' Chras_lee ', ' age ':#For I in Dic.items ():#print i,i[1] #一个变量循环字典#dic={' name ': ' Chras_lee ', ' age ':#For I in Enumerate (DIC):#print (i,i[1],dic[i[1]]) #使用enumerate循环字典#dic={' name ': ' Chras_lee ', ' age ':#For k,v in Dic.items ():#print (k,v) #两个变量循环字典##dic={' name ': ' Chras_lee ', ' age ':#For K in Dic.keys ():#print (K,dic[k]) #使用dic. Keys takes value##dic={' name ': ' Chras_lee ', ' age ':#For V in Dic.values ():#Print (v) #使用dic. Values directly out of value#dic={' name ': ' Chras_lee ', ' age ':#For K in DIC:#print (k,dic[k]) #常用方法#the direct for Loop dictionary is the key that iterates through the dictionary
    looping string    #   mes= ' Hello '  #  Span style= "COLOR: #008000" > for I in Mes:  #   p Rint (i) #for循环字符串  #   mes= ' Hello ' #   for I in enumerate (MES):  #   print i #使用enumerate将字符串以元组的方式遍历  #   mes= ' Hello '  #   for I in Mes[::-1]:  #   print (i) #倒着循环  
Loop List#l=[' A ', ' B ', ' C ']#For i in L:#print (i) #循环列表#l=[' A ', ' B ', ' C ']#For I in Enumerate (l):#print (i) #使用enumerate将列表以元组的方式遍历# #L = [' A ', ' B ', ' C ']#For I in l[::-1]:#print (i) #倒着循环
    round robin tuple    #   t= (' A ', ' B ', ' C ')  #   for I in T:  #   print (i) #循环元组  ##   t= (' A ', ' B ', ' C ')  #   for I in enumerate (t:  #   print (i) #使用enumerate将元组以元组的方式遍历  #   t= (' A ', ' B ', ' C ')  #   for I in t[:: -1]:  #   print (i) #倒着循环 / pre>

Python the next day-loop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.