Subscript index of the string

# String: Expression is an ordered sequence of characters 
# arbitrary character string in a character string in a determined position has a sequence number is 
# the number in the subscript or index or python subscript index 

# string saved character 
# demand: obtaining a character string in any one of 
a = " World " 
# Get R & lt 
# subscript index: starts from 0 and so on ... 0123 (calculated from the left to the right) 
a = RET1 [2 ]
 Print (RET1) 

# subscript index: starting from -1 and so -1-2-3-4 .... (calculated to be from right to left) 
RET2 a = [-3 ]
 Print (RET2) 

# a character has two subscripts a string index 

# demand: 
# IndexError: string index of OUT Range 
# string indices out of bounds 
ret3 = a [10]

 

Guess you like

Origin www.cnblogs.com/kangwenju/p/12688967.html