小白教程
所有教程
关于
Search
172.70.131.83
172.70.131.83
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python func slice”的源代码
本页内容
上一节:
Python_func_next
下一节:
Python_func_any
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:slice()}}[[Category:python3 built in functions|10]] = Python slice() 函数 = [[python built in functions|Python 内置函数]] == 描述 == '''slice()''' 函数实现切片对象,主要用在切片操作函数里的参数传递。 == 语法 == slice 语法: <sample title="" desc="" lang="python" hererun="1"> class slice(stop) class slice(start, stop[, step]) </sample> 参数说明: * start -- 起始位置 * stop -- 结束位置 * step -- 间距 == 返回值 == 返回一个切片对象。 以下实例展示了 slice 的使用方法: <sample title="" desc="" lang="python" hererun="1"> >>>myslice = slice(5) # 设置截取5个元素的切片 >>> myslice slice(None, 5, None) >>> arr = range(10) >>> arr [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> arr[myslice] # 截取 5 个元素 [0, 1, 2, 3, 4] >>> </sample> [[python built in functions|Python 内置函数]]
返回至“
Python func slice
”。
上一节:
Python_func_next
下一节:
Python_func_any