23、【python】range函数

rang(5):表示从0开始数,数5个数字(0,1,2,3,4)

rang(2,9)表示从2开始数,数到8(2,3,4,5,6,7,8)

 

例子1:这里的 printfor 是平级,结果输出一个数

image

image

 

例子2:这里的 print 是缩在for里面,结果每个输出

image

 

image      image

 

posted @ 2026-06-03 11:48  MoenyChen  阅读(6)  评论(0)    收藏  举报