在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Python/ python的range到底是如何運(yùn)作?

python的range到底是如何運(yùn)作?

它不是返回一個(gè)根據(jù)兩個(gè)或者三個(gè)參數(shù)確定的數(shù)組么? 為什么要得到數(shù)組還要加上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

2017年2月18日 01:12
編輯回答
哎呦喂

Python3 中,有專門的 range 對(duì)象了。
如果你要問(wèn)如何運(yùn)作的,可以看源碼: https://github.com/python/cpy...

2018年4月26日 21:40
編輯回答
情皺

range是一個(gè)類 # <class 'range'>
range(10)是一個(gè)對(duì)象
list 是一個(gè)類 # <class 'list'>
list(range(10)) 是把range對(duì)象轉(zhuǎn)為list對(duì)象啊,也就是常用的列表
源碼不好理解的話,可以看看官方文檔https://docs.python.org/3/lib...

2018年9月18日 17:16