Strings are quite useful Sequence Data Type for storing language text inside a Python Program. Moreover characters inside a string have specific order, which cannot be changes meaning Strings are Immutable. Also in case if your not aware of What are Strings in Python? then please check Python Strings article first and then only learn about Methods which can be applied on Strings.
Let’s get straight into What are String Methods in Python?
Below is a table containing all of String Methods with description.
String Method | Description |
---|---|
capitalize() | Returns a string with first letter in upper case |
casefold() | Returns a string with all letters in lower case |
center() | Takes in a parameter and return a centered string |
count() | Returns number of times some word occurred within a large string |
encode() | Returns encoded version of string |
endswith() | Returns true if string ends with some specified value |
expandtabs() | Setting tab size of a string |
find() | Looks into a specified string for some value(like a word) and returns position where it was found |
format() | Format specified value in a string |
format_map() | Format specified value in a string |
index() | Looks into a specified string for some value(like a word) and returns position where it was found |
isalnum() | Looks into the string and return True if all of its characters are alphanumeric, false otherwise |
isalpha() | Looks into the string and return True if all of its characters are from alphabet, false otherwise |
isdecimal() | Looks into the string and return True if all of its characters are decimals, false otherwise |
isdigit() | Looks into the string and return True if all of its characters are digits, false otherwise |
isidentifier() | Returns True if string is an identifier |
islower() | Checks if chracters inside string are in lower case, if so then returns True |
isnumeric() | Checks if chracters inside string are numeric, if so then returns True |
isprintable() | Checks if chracters inside string are printable, if so then returns True |
isspace() | Checks if chracters inside string are all whitespaces, if so then returns True |
istitle() | Return True if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise. |
issuper() | Returns True if only all of characters inside string are in UPPER CASE |
join() | Join elements of an iterable to end of string |
!just() | Returns string left justified in a string of length width, but if width is less/equal to len(string) then original string is returned. |
lower() | Converts all characters inside a string to lowercase |
lstrip() | Returns left trimmed version of string |
maketrans() | Returns translation table to be used in translations |
partition() | Returns a tuple made up by dividing string into three parts |
replace() | Returns a string where some value in string is replaced by some specified value |
rfind() rindex() | Goes through a string looking for some specified value and returns last position where that specified value is found |
rjust() | Returns right justified version of string |
rpartition() | Returns a tuple where string is parted into three parts |
rsplit() | Splits up string at specified separator and returns a Python List |
rstrip() | Returns a right trimmed version of string |
split() | Splits up string at specified separator and returns a Python List |
splitlines() | Returns a list after splitting string at line breaks |
strip() | Return trimmed version of string |
swapcase() | Swaps cases of charcters into a string – Turns LowerCase to UpperCase and Upper to Lower |
title() | Converts first character of each word in a string to Upper Case |
translate() | Returns a translated string |
upper() | Converts all characters of a string to Upper Case |
zfill() | Fill string with a specified number of 0 values at beginning |
More about Python Programming Language.
• Python Strings
• Built-in Functions in Python
• Sets in Python Programming Language
No Comments
Leave a comment Cancel