python3.1for循环及应用

时间:2019-06-29 18:26:25   收藏:0   阅读:99

#给定范围,进行循环
for i in range (0,5):
print(i)

#对序列进行遍历
list1=[1,2,3,4,5]
for i in list1:
print(i+1)


#对元组进行遍历
tuple1=(5,6,7,8,9,10)
for i in tuple1:
print(i)


#对字典key进行遍历
dict1={"name":"小明","age":"18"}
for i in dict1:
print(i)
#对字典value进行遍历
for i in dict1:
print(dict1[i])


#对集合进行遍历
jihe={"a","b","c"}
for i in jihe:
print(i)

技术分享图片

 

原文:https://www.cnblogs.com/lma0702/p/11107355.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!