Python标准库:内置函数slice(stop) slice(start, stop[, step])
2015-04-11 20:02
423 查看
本函数是实现切片对象,主要用在切片操作函数里的参数传递。
例子:
结果输出如下:
slice(None, 5, None)
[0, 1, 2, 3, 4]
蔡军生 QQ:9073204 深圳
例子:
#slice() myslice = slice(5) print(myslice) l = list(range(10)) print(l[myslice])
结果输出如下:
slice(None, 5, None)
[0, 1, 2, 3, 4]
蔡军生 QQ:9073204 深圳
相关文章推荐
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- Python标准库:内置函数range(stop) range(start, stop[, step])
- Python标准库:内置函数range(stop) range(start, stop[, step])
- Python标准库:内置函数range(stop) range(start, stop[, step])
- Python标准库:内置函数sum(iterable[, start])
- Python标准库:内置函数sum(iterable[, start])
- python的内建函数(BIF)range(start, stop, step)
- [转载]Python标准库:内置函数sum(iterable[, start])
- Python标准库:内置函数bytes([source[, encoding[, errors]]])
- Python标准库:内置函数dict(iterable, **kwarg)
- Python标准库:内置函数dict(mapping, **kwarg)
- Python标准库:内置函数divmod(a, b)
- Python标准库:内置函数divmod(a, b)
- Python标准库:内置函数chr(i)
- Python标准库:内置函数eval(expression, globals=None, locals=None)
- Python标准库:内置函数dict(**kwarg)
- Python标准库:内置函数classmethod(function)
- Python标准库:内置函数enumerate(iterable, start=0)