Method | Description |
---|---|
Converts the first character to upper case. | |
Converts string into lower case. | |
Returns a centered string. | |
Returns the number of times a specified value occurs in a string. | |
Returns an encoded version of the string. | |
Returns true if the string ends with the specified value. | |
Sets the tab size of the string. | |
Searches the string for a specified value and returns the position of where it was found. | |
Formats specified values in a string. | |
Searches the string for a specified value and returns the position of where it was found. | |
Joins the elements of an iterable to the end of the string. | |
Converts a string into lower case. | |
Returns a left trim 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. | |
Splits the string at line breaks and returns a list. | |
Returns true if the string starts with the specified value. | |
Returns a trimmed version of the string. | |
Swaps cases, lower case becomes upper case and vice versa. | |
Converts the first character of each word to upper case. | |
Returns a translated string. | |
Converts a string into upper case. |
()
Method
The
while making all other characters in the string lowercase letters.
It is simply known as to convert letters from upper case letterss to lower case letters vice versa.
a="hello RGUKT"
b=a.capitalize ()
print(b)
()
Method
The
Python String
a="PYThoN" #string containing lower and upper case leters
b=a.casefold ()
print (b) #out put is python
()
Method
Python String
Python String
The
a="this is python" #this string containng alphabets and space
b=a.center (24,'*')
print (b) #Output is ***this is python***
()
Method
The
Python String
a="hello rguktians form rgukt"
b=a.count ('r' ) #counting number of 'r' in given string
print (b) #Output is 3
()
Method
The
Python String encode() converts a string value into a collection of bytes, using an encoding scheme specified by the user.
a="this is python"
b=a.encode ()
print(b) #Output is b'this is python'
()
Method
The
Python String
a="this is rgukt"
b=a.endswith ('rgukt' ) # checking given string is ends with 'rgukt' whether it is true or false
print (b) # Output is True
()
Method
The expandtabs() method returns a copy of string with all tab characters
a="this \t is \t rgukt"
b=a.expandtabs ()
print(b) #Output is this is rgukt
()
Method
Python String
If it is not found, then it returns -1.
a="hello rguktians this is rgukt web"
b=a.find ('this' )
print (b) # Output is 16
()
Method
The string
Python string
Sometimes we want to make generalized print statements in that case instead of writing print statement every time we use the concept of formatting.
a="this is code of formate in {}"
print (a.format ("strings" )) # Output is 'this is code of formate in strings'
()
Method
Python String
The
If the substring is not found, it raises an exception.
a="this is from rgukt web"
b=a.index ('from' )
print (b) #Output is '8'
()
Method
This function joins elements of a sequence and makes it a string.
The
A string must be specified as the separator.
a = ['R' ,'G' ,'U' ,'K' ,'T' ]
print ("" .join (list1)) #Output is 'RGUKT'
()
Method
Python String
If no argument is passed, it removes leading spaces.
a=" rgukt srikakulam" #string containg left space
print(a.lstrip ()) #Output is 'rgukt srikakulam'
()
Method
Python String
In this article, we will cover how to convert uppercase to lowercase in Python.
a="RguKt SrIkakUlAm" # string contains both upper and lower case alphabets
b=a.lower ()
print (b) # Output is 'rgukt srikakulam'
()
Method
Python String
Here, the separator is a string that is given as the argument.
c="this is rguktweb from rgukt sklm"
print (c.partition ("from" )) #Output is ('this is rguktweb ', 'from', ' rgukt sklm')
()
Method
The
a="rgekt"
b=a.replace ("e" ,"u" )
print (b) #Output is 'rgukt'
()
Method
Python String
The function returns a list of lines in the string, including the line break(optional).
a="this is rgukt web \r from \n rgukt sklm"
print (a.splitlines ()) #Output is ['this is rgukt web', ' from', ' rgukt sklm']
()
Method
Python String startswith() method returns True if a string starts with the specified prefix (string).
If not, it returns False.
a="this is rgukt web"
print(a.startwith ("this" )) #Output is True
print(a.startwith ("rgukt" )) #Output is False
()
Method
a="rgukt web from rgukt"
print (a.strip ('rgukt' )) #Output is web from
()
Method
The string
a="this is RguKt Web froM RguKt SkLm"
b=a.swapcase ()
print (b) #Output is 'THIS IS rGUkT wEB FROm rGUkT sKlM'
()
Method
The String
a="this is rgukt web team"
b=a.title ()
print (b) #Output is 'This Is Rgukt Web Team'
()
Method
()
Method
a="This is rGukt web Team from RGukt"
b=a.upper ()
print (b) #Output is 'THIS IS RGUKT WEB TEAM FROM RGUKT'