Python笔记-built-in functions之range class的step参数说明

class range(startstop[, step])

 

For a positive step, the contents of a range r are determined by the formula r[i] start step*i where >= 0 and r[i] stop.

For a negative step, the contents of the range are still determined by the formula r[i] start step*i, but the constraints are >= 0 and r[i] stop.

A range object will be empty if r[0] does not meet the value constraint. Ranges do support negative indices, but these are interpreted as indexing from the end of the sequence determined by the positive indices.

posted @ 2022-09-19 22:23  CLAYJJ  阅读(19)  评论(0编辑  收藏  举报