Disclaimer: The following links and descriptions come from the web, many of them from the novice tutorial
One, String str
Python string formatting symbols:
| %c |
Formatting characters and their ASCII code |
| %s |
formatting strings |
| %d |
formatting integers |
| Function |
Describe |
|
|
| Print (Name[0]) |
Value by index (positive fetch + reverse fetch): can only take |
| Print (Name[0:6:2]) |
Slicing ( Gu Tou regardless of tail , step) |
| Len () |
Length |
| Strip (' *! ') |
The default is to remove blank or specified characters on both sides , which is typically used for user interaction |
Lstrip ()
|
A space or specified character used to truncate the left edge of a string |
| Rstrip () |
Used to truncate the right edge of a string or specify a character |
| Split () |
slices A string by specifying a delimiter , separating only the NUM substring if the parameter num has a specified value |
Rsplit () |
The Python Rsplit () method splits a string by specifying a delimiter and returns a list with the default delimiter of all null characters, including spaces, line breaks (\ n), tabs (\ t), and so on. Similar to the split () method, except that the split begins at the end of the string.
|
Lower () |
The Python lower () method converts all uppercase characters in a string to lowercase . |
| Upper () |
The Python Upper () method converts lowercase letters in a string to uppercase letters |
| StartsWith () |
The StartsWith () method is used to check whether the string starts with the specified substring , or True if it is, or False if it is returned. If the parameter beg and end specify a value, the check is within the specified range. |
| EndsWith () |
The EndsWith () method is used to determine whether the string ends with the specified suffix and returns false if the end of the specified suffix returns true. The optional parameter "start" and "end" are the starting and ending positions of the retrieved string. |
Format () |
The basic syntax is to replace the previous% with {} and: .
The Format function can accept no more than one parameter, and the position can be out of order. |
| Join () |
method is used to generate a new string from the elements in the sequence with the specified character connection. |
Replace () |
Replace the old (older string)in the string with new, or if you specify the third parameter max, the replacement does not exceed Max times. |
IsDigit () |
method to detect whether a string consists only of numbers |
|
|
|
|
Find ()
|
The Find () method detects whether the string contains substrings of STR, and if you specify beg (start) and end (end) ranges, the check is included in the specified range, and if the specified range contains the specified index value, the return index value is the starting position in the string. Returns 1 if the index value is not included. |
RFind () |
Returns the position of the last occurrence of the string, or 1 if there is no match. |
Index () |
The index () method detects whether a substring contains substrings in str, and if you specify beg (start) and end (end) ranges, the check is contained within the specified range, just like the Python find () method, except that STR does not report an exception in string. |
Rindex () |
Returns a substring of STR in the last occurrence of the string, and if there is no matching string to report an exception, you can specify an optional parameter [Beg:end] to set the search interval. |
Count () |
Used to count the occurrences of a character in a string. The optional parameters are the start and end positions of the string search. |
Center () |
The center () method returns a string that specifies the width of the center, Fillchar is the filled character, and the default is a space. |
Ljust () |
The Ljust () method returns the left alignment of the original string and fills the new string with a space to the specified length. Returns the original string if the specified length is less than the length of the original string. |
Rjust () |
Rjust () returns the right alignment of the original string and fills the new string with a space of length width. Returns the original string if the specified length is less than the length of the string. |
Zfill () |
The Python Zfill () method returns a string of the specified length, the original string is right-aligned, and the front padding is 0. |
Expandtabs () |
The Expandtabs () method turns the tab symbol (' \ t ') in the string to a space, and the tab symbol (' \ t ') has a default number of spaces of 8. |
Captalize () |
Python capitalize () capitalizes the first letter of a string and other letters to lowercase. For 8-bit byte encoding needs to be based on the local environment. |
Swapcase () |
The Swapcase () method is used to convert the uppercase and lowercase letters of a string. |
Title () |
The title () method returns a "caption" string, meaning that all words start with uppercase and the remaining letters are lowercase (see istitle ()). |
|
|
Second, list of three, Ganso four, dictionary dict five, set
Python Tour: basic Function Method Collation