Home >>Python String Methods
Python has a set of its own built-in methods that can be used on strings.
Method | Description |
---|---|
capitalize() | It is used to convert the first character to upper case. |
casefold() | It is used to convert string into lower case. |
center() | It is used to return a centered string. |
count() | It is used to return the number of times a specified value occurs in a string. |
encode() | It is used to return an encoded version of the string. |
endswith() | It is used to return true if the string ends with the specified value. |
expandtabs() | It is used to set the tab size of the string. |
find() | It is used to search the string for a specified value and return the position of where it was found. |
format() | It is used to format specified values in a string. |
format_map() | It is used to format specified values in a string. |
index() | It is used to search the string for a specified value and return the position of where it was found. |
isalnum() | It is used to return True if all characters in the string are alphanumeric. |
isalpha() | It is used to return True if all characters in the string are in the alphabet. |
isdecimal() | It is used to return True if all characters in the string are decimals. |
isdigit() | It is used to return True if all characters in the string are digits. |
isidentifier() | It is used to return True if the string is an identifier. |
islower() | It is used to return True if all characters in the string are lower case. |
isnumeric() | It is used to return True if all characters in the string are numeric. |
isprintable() | It is used to return True if all characters in the string are printable. |
isspace() | It is used to return True if all characters in the string are whitespaces. |
istitle() | It is used to return True if the string follows the rules of a title. |
isupper() | It is used to return True if all characters in the string are upper case. |
join() | It is used to Join the elements of an iterable to the end of the string. |
ljust() | It is used to return a left justified version of the string. |
lower() | It is used to convert a string into lower case. |
lstrip() | It is used to return a left trim version of the string. |
maketrans() | It is used to return a translation table to be used in translations. |
partition() | It is used to return a tuple where the string is parted into three parts. |
replace() | It is used to return a string where a specified value is replaced with a specified value. |
rfind() | It is used to search the string for a specified value and return the last position of where it was found. |
rindex() | It is used to search the string for a specified value and return the last position of where it was found. |
rjust() | It is used to return a right justified version of the string. |
rpartition() | It is used to return a tuple where the string is parted into three parts. |
rsplit() | It is used to split the string at the specified separator and return a list. |
rstrip() | It is used to return a right trim version of the string. |
split() | It is used to split the string at the specified separator and return a list. |
splitlines() | It is used to split the string at line breaks and return a list. |
startswith() | It is used to return true if the string starts with the specified value. |
strip() | It is used to return a trimmed version of the string. |
swapcase() | It is used to swap cases, lower case becomes upper case and vice versa. |
title() | It is used to convert the first character of each word to upper case. |
translate() | It is used to return a translated string. |
upper() | It is used to convert a string into upper case. |
zfill() | It is used to fill the string with a specified number of 0 values at the beginning. |