Method description
String.capitalize () capitalizes the first character of a string
String.center (width) returns the center of the original string and fills the new character with the width of length with a space
String
String.count (str, beg=0,
End=len (String) returns the number of occurrences of STR in a string, if beg or end is specified
Returns the number of STR occurrences within a specified range
String.decode (encoding= ' UTF-8 ',
errors= ' strict ') decodes a string in encoding specified encoding format, if an error is reported by default
ValueError exception, unless errors specifies ' ignore ' or
' Replace '
String.encode (encoding= ' UTF-8 ',
errors= ' strict ') a encodes a string in the encoded format specified by encoding, if an error is reported by default to a
ValueError exception, unless errors specifies ' ignore ' or ' replace '
String.endswith (obj, beg=0,
End=len (String)) B,e checks if the string ends with obj, and if beg or end is specified, the check refers to the
If it is, returns True, or False if the range is set to end in obj.
String.expandtabs (tabsize=8) Turns the tab symbol in string strings to a space, the default null
The number of lattice tabsize is 8.
String.find (str, beg=0,
End=len (String) detects if Str is contained in a string, and if beg and end specify a range,
Check to see if it is contained within the specified range, or if it returns the index value at the beginning, otherwise
Returns-1
String.index (str, beg=0,
End=len (String) is the same as the Find () method, except that STR does not report an exception if it is not in a string.
String.isalnum () A, B, C R if the string has at least one character and all characters are letters or numbers, return
return true, otherwise false
String.isalpha () A, B, C returns True if the string has at least one character and all characters are letters.
otherwise returns false
String.isdecimal () b, C, D returns True if the string contains only a decimal number, otherwise false.
String.isdigit () B, C returns True if String contains only a number, otherwise false.
String.islower () b, c if the string contains at least one case-sensitive character, and all of these (distinguish
Uppercase) characters are lowercase, return true, or false
String.isnumeric () b, C, D returns True if the string contains only numeric characters, otherwise false
String.isspace () B, C returns True if the string contains only spaces, otherwise false.
String.istitle () B, C returns True if String is a heading (see title ()), otherwise false
String.isupper () b, c if the string contains at least one case-sensitive character, and all of these (distinguish
Uppercase or lowercase), returns true, otherwise false
String.Join (seq) Merges (concatenates) takes a string as a delimiter, and all the elements in the SEQ
(The string representation) is merged into a new string
String.ljust (width) returns the left alignment of an original string and fills the new string with a space of length width
String.Lower () converts all uppercase characters in a string to lowercase.
String.lstrip () truncates the left space of a string
String.partition (str) e is somewhat like a combination of find () and split (), starting from the first position in STR,
Divides a string of strings into a tuple of 3 elements
(STRING_PRE_STR,STR,STRING_POST_STR) If the string does not contain
STR is string_pre_str = = string.
String.Replace (str1, STR2,
Num=string.count (STR1)) replaces str1 in string with str2, if NUM is specified,
The replacement does not exceed num times.
String.rfind (str, Beg=0,end=len (string)) is similar to the Find () function, but starts from the right.
Find.
String.rindex (str, Beg=0,end=len (string)) is similar to index (), but starts from the right.
String.rjust (width) returns the right alignment of the original string and fills the new string with a space of length width
String.rpartition (str) e is similar to the partition () function, but looks up from the right.
String.rstrip () Deletes a space at the end of a string string.
String.Split (str= "", Num=string.count (str)) slices a string with the str delimiter, if num
With the specified value, only the NUM substring is delimited
String.splitlines (Num=string.count (' \ n ')) B, C, separated by rows, returns a containing row as an element
The list, if NUM specifies that only the slice num
Yes.
String.startswith (obj, Beg=0,end=len (string)) B, E checks whether the string starts with obj, or
Returns TRUE, otherwise false is returned. If
Beg and end specify values, the check is within the specified range
String.strip ([obj]) executes Lstrip () and Rstrip () on string
String.swapcase () flips the casing in a string
String.title () B, C returns the string "header", meaning all words start with uppercase, the rest
Letters are lowercase (see istitle ())
String.translate (str, del= "") converts a string character according to the table given by STR, which contains 256 characters,
The characters to filter out are placed in the Del parameter
String.upper () converts lowercase letters in string to uppercase
String.zfill (width) returns a string of length width, the original string is right-aligned, the front padding
0
This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1721158
Python String functions