python3.1for循环及应用

2020-12-13 04:17

阅读:620

标签:ict   集合   image   int   循环   range   技术   value   for   

#给定范围,进行循环
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)

技术图片

 

python3.1for循环及应用

标签:ict   集合   image   int   循环   range   技术   value   for   

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


评论


亲,登录后才可以留言!