Based on the python2

If python3, print(STR [:])

str= '0123456789'print str[0:3] # Cut the first to third characters
print str[:] # Intercepts all characters of the string
print str[6:] # Cut the seventh character to the end
print str[: -3] # intercepts from the beginning to the last character
print str[2] # intercepts the third character
print str[-1] # intercepts the penultimate character, which is the last character
print str[: : -1] # Create a string in reverse order of the original string
print str[-3: -1] # Intercepts the character before the last and last characters
print str[-3:] # Cut the third from the bottom to the end
print str[: -5: -3] # 9 (8, 7) 6, 5
print str[: -5: -1] # reverse interception
Copy the code

The output

012 
0123456789 
6789 
0123456 
2 
9 
9876543210 
78 
789 
96 
9876
Copy the code