A, python string type Overview
Definition: single quotation marks \ double quotes \ three marks, a string of characters name = 'Test'
name = 'test' print(type(name)) -------------------------------------------- <class 'str'>
String: a bunch of characters defined in quotes (single quotes, double quotes, triple quotes) in the
state: descriptive content, such as name, gender, nationality
Second, the index of the string (index)
Among all the python are characterized by the ordered sequence, the concept of their difference whether the index sequence may be modified;
The index when we beginner we can understand the index of the string;
Strings are referred to each individual element of a character is the character string;
Such as string 'while', it will be understood that in the following figure conceptual index, the index number is zero;
w |
h |
i |
l |
e |
0 |
1 |
2 |
3 |
4 |
Index usage, while taking a single element, using the STRING [index] is the index corresponding to the index number of the element;
String taken: string [start: end], to give the corresponding element index range, the starting end of that range, without trailing end, the default is taken in a direction from left to right;
Interception step: string [start: end: step] be taken in accordance with step step compartment;
Grammar sections: [start: end: step]
Note: Select the closed section belonging to the left and right open type, that is, from the start "start" position to the "end" before the end of a bit (do not include the end of the bit itself).
Default emulated: string [start: end, step] these three parameters have default values, start; the default value is 0; end end element string is not the default value; the default value STEP 1
Find string |
count |
Counting function, the number of characters in the string returned from among a set |
find |
Find, left to return to the first character of a specified index, or -1 not found |
|
index |
Find, left to return to the first index of specified characters, can not find the error |
Vatican
Justice is
Each side