Python Func Slice
# Python2.x Python slice() Function
[ Python Built-in Functions](#)
* * *
## Description
The **slice()** function creates a slice object, primarily used for parameter passing in slicing operations.
## Syntax
slice syntax:
class slice(stop)class slice(start, stop[, step])
Parameter explanation:
* start -- Starting position
* stop -- Ending position
* step -- Step (interval)
## Return Value
Returns a slice object.
## Example
The following example demonstrates the usage of slice:
>>>myslice = slice(5)# Set a slice to capture 5 elements>>>myslice slice(None, 5, None)>>>arr = range(10)>>>arr[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>>arr# Capture 5 elements[0, 1, 2, 3, 4]>>>
[ Python Built-in Functions](#)
YouTip