chipinzhen
class range(object) | range(stop) -> range object | range(start, stop[, step]) -> range objectReturn an object that produces a sequence of integers from start (inclusive) | to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1. | start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3. | These are exactly the valid indices for a list of 4 elements. | When step is given, it specifies the increment (or decrement).在python环境下输入help(range)可以看到这个对象的内部定义就是从开始到结尾的 现在你的问题中1比10小 就会不输出相反 在python队列等可迭代对象的操作中,-1就有意义了比如listA = [0,1,2,3,4,5,6,7,8,9]listA[-1] 表示的是从列表尾部最后一个 即为9listA[-2] 表示倒数第二个 为8所以前者不输出,后者输出