它不是返回一个根据两个或者三个参数确定的数组么? 为什么要得到数组还要加上list
Python range (start, end) never include end it has a very simple answer because index always starts with ZERO in python. if you count total numbers between range (5) you will get [0,1,2,3,4] i.e. total count is 5.
return result determined by value constraints. it will return empty if value constraint doesn't meet some of the value constraints are step value cannot be zero or greater than stop
2 回答5.1k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
range是一个类 # <class 'range'>
range(10)是一个对象
list 是一个类 # <class 'list'>
list(range(10)) 是把range对象转为list对象啊,也就是常用的列表
源码不好理解的话,可以看看官方文档https://docs.python.org/3/lib...