好用的for循环与range
-
for循环
# for 变量 in 可迭代对象: # pass s = "1234567890" for each in s: # 遍历字符串 print(each) # 1 2 3 4 5 6 7 8 9 0 print(each) # 0 注意
-
占位符
pass 和 ...
-
range
-
语法range(start,end,step): 范围,从start到end,不包含end,步长step默认是1
-
python3中打印range()会打印本身,python2中会打印出列表
for each in range(1,10): print(each) # 1 2 3 4 5 6 7 8 9
-