#给定范围,进行循环
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
时间: 2024-11-01 17:11:43