String Method
String Method
capitalize() It capitalizes the first character of the String. This function is deprecated in python3
center(width ,fillchar) It returns a space padded string with the original string centred with equal number of left and right
spaces.
count(string,begin,end) It counts the number of occurrences of a substring in a String between begin and end index.
decode(encoding = 'UTF8', errors = Decodes the string using codec registered for encoding.
'strict')
encode() Encode S using the codec registered for encoding. Default encoding is 'utf-8'.
endswith(suffix It returns a Boolean value if the string terminates with given suffix between begin and end.
,begin=0,end=len(string))
expandtabs(tabsize = 8) It defines tabs in string to multiple spaces. The default space value is 8.
find(substring ,beginIndex, endIndex) It returns the index value of the string where substring is found between begin index and end index.
index(subsring, beginIndex, endIndex) It throws an exception if string is not found. It works same as find() method.
isalnum() It returns true if the characters in the string are alphanumeric i.e., alphabets or numbers and
there is at least 1 character. Otherwise, it returns false.
isalpha() It returns true if all the characters are alphabets and there is at least one character, otherwise False.
isdecimal() It returns true if all the characters of the string are decimals.
isdigit() It returns true if all the characters are digits and there is at least one character, otherwise False.
islower() It returns true if the characters of a string are in lower case, otherwise false.
isprintable() It returns true if all the characters of s are printable or s is empty, false otherwise.
isupper() It returns false if characters of a string are in Upper case, otherwise False.
isspace() It returns true if the characters of a string are white-space, otherwise false.
istitle() It returns true if the string is titled properly and false otherwise. A title string is the one in which the first c
is upper-case whereas the other characters are lower-case.
isupper() It returns true if all the characters of the string(if exists) is true otherwise it returns false.
lstrip() It removes all leading whitespaces of a string and can also be used to remove particular character from lea
partition() It searches for the separator sep in S, and returns the part before it, the separator itself, and the part after
separator is not found, return S and two empty strings.
replace(old,new[,count]) It replaces the old sequence of characters with the new sequence. The max characters are replaced if max
rjust(width,[,fillchar]) Returns a space padded string having original string right justified to the number of characters specified.
rstrip() It removes all trailing whitespace of a string and can also be used to remove particular character from trail
rsplit(sep=None, maxsplit = -1) It is same as split() but it processes the string from the backward direction. It returns the list of words in th
If Separator is not specified then the string splits according to the white-space.
split(str,num=string.count(str)) Splits the string according to the delimiter str. The string splits according to the space if the delimiter is not p
It returns the list of substring concatenated with the delimiter.
splitlines(num=string.count('\n')) It returns the list of strings at each line with newline removed.
startswith(str,beg=0,end=len(str)) It returns a Boolean value if the string starts with given str between begin and end.
title() It is used to convert the string into the title-case i.e., The string meEruT will be converted to Meerut.
translate(table,deletechars = '') It translates the string according to the translation table passed in the function .