1.for … in 循环
循环,遍历,迭代 都是指把容器中的数据一个一个获取出来
lst = [1,2,3,4,5]
i = 0
while i<len(lst):
print(lst[i])
i...可迭代对象( 通常用到的是: 容器类型数据 , range对象 , 迭代器 )
2.遍历集合
container = {
"taibai","wusir","wuchao","bijiao"}...for i in container:
print(i)
3.遍历列表
''' Python学习交流,免费公开课,免费资料, 免费答疑,系统学习加QQ群:579817333 '''
container...,b = {"a","b"} 集合有局限性,因为无序;
a,b ={
"a":1,"b":2}
print(a,b)
8.遍历等长的二级容器
''' Python学习交流,免费公开课,免费资料,...for 一般用于数据的遍历
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/170074.html原文链接:https://javaforall.cn