python-- string interception

= STR '0123456789 '
 print STR [0:. 3] # , taken first to third character 
print STR [:] # taken all the character string 
print STR [. 6:] # taken to the end of the seventh character 
print STR [: -. 3] # , taken from the beginning until the antepenultimate characters 
Print STR [2] # taken third character 
Print STR [-1] # taken penultimate character 
Print STR [:: -. 1] # creating a reverse order of the strings and the original string 
print STR [-3: -1] # taken characters and the bottom third of the penultimate one previous 
print STR [-3:] # taken countdown to the end of the third 
print str [: - 5: -3] # reverse the interception, did not thoroughly understand the specific what do you mean?

A corresponding output:

012
0123456789
6789
0123456
2
9
9876543210
78
789
96

 

Guess you like

Origin www.cnblogs.com/Lynn0101/p/10944428.html