String values directly str [0], because the slice method

a = 'hellokity'

print(a[0])

h

# Take three substrings to 8 characters, left closed right open 
# print (a [2:. 8])
# print (a [2:. 8: 2]) # every two take a
# print (a [ 2:]) taken to the end #
# print (a [: 8] ) # taken from the head
# print (a [:]) # taken from the beginning to the end
# print (a [:: 2] ) # interval from start to finish a take one step is 2
# Print (a [: -. 1]) from the head to the penultimate #
# print (a [1:] ) # taken from the second to the last
# print (a [:: - 1]) # counting down, taken from the first string ,, a countdown to the first reverse

 

Guess you like

Origin www.cnblogs.com/hpzyang/p/11408008.html