编程语言
首页 > 编程语言> > python切片使用

python切片使用

作者:互联网

举例1:

list=[1,2,3,4,5]

取值第一个值:
list[0]
其范围内的值:
list[2:4]
取末尾的值:
a=(list[-1])
list[-1:]
从后往前面取值:
list[-1:]
list[-2:]
list[:-3:-1]

举例2:

mage=list(range(1,101))
max_count=len(mage)

n=0
while n
print(mage[n:n+10])

标签:count,从后,python,list,切片,举例,使用,取值,mage
来源: https://blog.csdn.net/weixin_44880796/article/details/122528568