Python Learning Note 2: Strings
Summary : strings are immutable variables and cannot be modified by subscript
The method of the string does not change the original value of the string, but it is reborn into a string
One or 3 ways of writing--single quotation marks, double quotes, three quotation marks
Second, subscript and slicing
Subscript: The position of each character in the string, also called the index. Strname[n], which represents the value of the character that strname the string's subscript to N.
Slice : The value of a subscript interval to take a string. STRNAME[N:M], indicating strname the string, subscript N to M in this interval value, note n:m value, Gubai disregard.
Three, String traversal
In and not in
For loop traversal string
Iv. Methods of strings
1, Upper (), lower (), Isupper (), Islower ()--case conversion and case sensitivity
2, IsX
Isalnum () Determines whether a string contains only numbers and letters
Isalpha () to determine if the string contains only English letters
IsDigit () Determines whether a string contains only numbers
3. Find () Method--Find the index of the first occurrence of the string
4. Format () Method--string formatting
5. Join () method --Connect an iterative object through a string
1) Connect an iterative object-string, such as *, through a string
2) Connect an iterative object-the tuple/list element through a string, such as *
3) through a string, such as *, to connect an iterative object-the element in the dictionary (because traversing the dictionary is actually the key value of traversing the dictionary)
6, Strip (), Lstrip (), Rstrip () method--go to the left and right side of the space to enter, remove the left side of the space carriage return, remove the blank space.
7.Split () method --cut the string with an identity as standard, return a list
8. Replace () method--replacement
9, string.ascii--print ASCII code letter
Python Learning Note 2: Strings