Python - String Methods

Python - String Methods


The Python has a number of methods and functions that are available for use with strings. These methods and functions are listed below in alphabetical order. For more details about any one of these, please visit its page.

String Methods & Functions
MethodsDescription
Converts first character of first world into uppercase and rest into lowercase
The Python has a number of methods and functions that are available for use with strings. These methods and functions are listed below in alphabetical order. For more details about any one of these, please visit its page. Converts string into lower case
Returns a centered string
Returns the number of times a specified value occurs in a string
String Methods & Functions Returns an encoded version of the string
Returns true if the string ends with the specified value
Methods Sets the tab size of the string
Description Searches the string for a specified value and returns the position of where it was found
Formats specified values in a string
capitalize() Formats specified values in a string
Returns the index number for first occurrence of specified character sequence in the string
Converts first character of first world into uppercase and rest into lowercase Returns true when all characters of the string are alphanumeric, else returns false
Returns true when all characters of the string are alphabet, else returns false
casefold() Returns true when all characters of the string are decimals, else returns false
Returns true when all characters of the string are digits, else returns false
Converts string into lower case Returns true when the string is an identifier, else returns false
Returns true when all characters of the string are in lowercase, else returns false
center() Returns true when all characters of the string are numeric, else returns false
Returns true when all characters of the string are printable, else returns false
Returns a centered string Returns true when all characters of the string are whitespaces, else returns false
Returns true when the characters of the string is in title format, else returns false
count() Returns true when all characters of the string are in uppercase, else returns false
Joins the elements of an iterable to the end of the string
Returns the number of times a specified value occurs in a string Returns a left justified version of the string
Converts all characters of the string into lowercase
encode() Returns a left trim version of the string
Returns a translation table to be used in translations
Returns an encoded version of the string Returns a tuple where the string is parted into three parts
Returns a string where a specified value is replaced with a specified value
endswith() Searches the string for a specified value and returns the last position of where it was found
Searches the string for a specified value and returns the last position of where it was found
Returns true if the string ends with the specified value Returns a right justified version of the string
Returns a tuple where the string is parted into three parts
expandtabs() Splits the string at the specified separator, and returns a list
Returns a right trim version of the string
Sets the tab size of the string Splits the string at the specified separator, and returns a list
Splits the string at line breaks and returns a list
find() Returns true if the string starts with the specified value
Returns a trimmed version of the string
Searches the string for a specified value and returns the position of where it was found convert all lowercase characters into uppercase and uppercase characters into lowecase
Converts all characters of the string in title format.
format() Returns a translated string
Converts all characters of the string into uppercase
Formats specified values in a string Fills the string with a specified number of 0 values at the beginning
FunctionsDescription
Returns total number of characters in the string.