str ="0123456789"Print("Print the No. 0 element:", str[0])Print("a negative number represents the last nth element, and 1 represents the last element of the countdown:", str[-1])Print("shard operation, Str[start:end], start is included in the result and end does not:", Str[1:5])Print("after a colon does not write the expression from start to end:", str[5:])Print("represents the second element from the bottom to the end:", str[-2:])Print("represents the second-to-last element from the reciprocal sixth element, but does not contain the penultimate element:", str[-6:-2])Print("Start does not write a representation from the beginning to end, but does not contain end:", Str[:4])Print("start and end are not written to represent the entire list:", str[:])Print("support Step, the step is a positive number for each n from start to end to print one:", Str[::2])Print("A negative step indicates that one is printed from end to start every n number:", str[::-2])Print("if end is smaller than start, the step must be negative otherwise an error occurs:", Str[-1:-6:-1])
Python lists and shards