String indexing and slicing
1. String index
analysis:
- String has its own corresponding index information
- The index value starts from 0 until the last character;
- The index value can start from -1 (the last character) until the first character;
- If the index is out of range, the system will report an Error IndexError .
2. String slicing
Slicing : You can arbitrarily select consecutive segments in the string
3. Get the index value of the specified character in the string
Usage : stringObject. index ("specifiedCharacter")