Python基础教程:使用for循环的用法.pdf
Python基础教程:for循环用法
1.for ... in循环循环,遍历,迭代都是指把容器中的数据一个一个获取出来
lst = [1,2,3,4,5]
for i in lst:
print(i)
可以通过for循环获取集合中的值
setvar = {"a","b","c"}
for i in setvar:
print(i)
2.遍历集合
container = {"taibai","wusir","wuchao","bijiao"}
for i in container:
print(i)
3.遍历列表
container = ["taibai","wusir","wuchao","bijiao"]
for i in container:
print(i)
4.遍历元组containe
用户评论