Python标准库:内置函数slice(stop) slice(start, stop[, step])
2017-03-01 09:17
309 查看
转自:http://blog.csdn.net/caimouse/article/details/44998357
本函数是实现切片对象,主要用在切片操作函数里的参数传递。
例子:
#slice()
myslice = slice(5)
print(myslice)
l = list(range(10))
print(l[myslice])
结果输出如下:
slice(None, 5, None)
[0, 1, 2, 3, 4]
本函数是实现切片对象,主要用在切片操作函数里的参数传递。
例子:
#slice()
myslice = slice(5)
print(myslice)
l = list(range(10))
print(l[myslice])
结果输出如下:
slice(None, 5, None)
[0, 1, 2, 3, 4]
相关文章推荐
- 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标准库:内置函数dict(iterable, **kwarg)
- Python标准库:内置函数chr(i)
- Python标准库:内置函数dict(mapping, **kwarg)
- Python标准库:内置函数divmod(a, b)
- Python标准库:内置函数divmod(a, b)
- Python标准库:内置函数eval(expression, globals=None, locals=None)
- Python标准库:内置函数dict(**kwarg)
- Python标准库:内置函数classmethod(function)
- Python标准库:内置函数enumerate(iterable, start=0)
- Python标准库:内置函数bytes([source[, encoding[, errors]]])