基本语法:
<font color="#e74f4c">for </font>临时变量 <font color="#e74f4c">in</font> 待处理数据集(序列) <font color="#e74f4c">:</font><br> 循环满足条件时执行的代码
与while循环的去区别
for循环是<font color="#e74f4c">无法定义循环条件</font>的,只能从被<font color="#e74f4c">处理的数据集中,依次取出内容</font>进行处理
range语句:
语法1:
range(num)
例:rangge(5)取得得数据是:[0,1,2,3,4]
语法2:
range(num1,num2)
例:rangge(5,10)取得得数据是:[5,6,7,8,9]
语法3:
range(num1,num2,step)
数字之间得步长,以step为准(step默认为1)
例:rangge(5,10,2)取得得数据是:[5,7,9]