String method
String.digits: String containing the number 0-9
String.letters: A string containing all letters (uppercase or lowercase)
String.lowercase: A string containing all lowercase letters
String.printable: A string containing all printable characters
String.punctuation: A string containing all punctuation
String.uppercase: A string containing all uppercase letters
The Find method can look up substrings in a longer string. Returns the leftmost index where the substring is located. Returns 1 if not found
>>> ' with a Moo-moo here,and a moo-moo there '. Find (' moo ') '
7
The Find method of the string does not return a Boolean value if no return is 0 proof that a substring was found at index 0 position
>>>subject.find ("111", 0, 1); 0 is the starting point 1 is the terminating point
Appendix Rfind,index,rindex,count,startwith,endswith
Two joins
The Join method is a very important string method, which is the inverse method of the split method used to concatenate the elements in the sequence
<<<seq=[' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 '];
seq= "+" #以 + connection string to produce a new string
Seq.join (seq);
1+2+3+4+5+6
Lower method returns the lowercase letter of a string
>>> ' Trodheim Hammer Dance '. Lower ()
' Trodheim Hammer Dance '
Appendix: islower,capitalize# Converts the first letter of the character into uppercase, Swapcase,title,istitle,upper,isupper
The Replace method returns a string after all occurrences of a string have been replaced
>>> ' This was a test '. Replace (' is ', ' EEZ ');
Theez EEZ a test
If you encounter the "Find and replace" feature in a word-processing program, you don't question the usefulness of this method.
Split this is a very important string method it is the inverse of the join method used to split the string into a sequence
>>> ' 1+2+3+4+5 '. Split ("+")
[' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ']
The Strip method returns a string that strips both sides (excluding interior) spaces
Appendix: Lstrip Rstrip
The Translate method, like the Replace method, can replace some characters in some strings in a string
Python uses strings