Latest web development tutorials

Python3 rstrip () method

Python3 string Python3 string


description

rstrip () to delete the specified character string end of the string (default is a space).

grammar

rstrip () method syntax:

str.rstrip([chars])

parameter

  • chars - the specified character deleted (default is blank)

return value

Return new string generation deleted at the end of the string at the specified character string after.

Examples

The following example shows rstrip () function to use:

#!/usr/bin/python3

str = "     this is string example....wow!!!     "
print (str.rstrip())
str = "*****this is string example....wow!!!*****"
print (str.rstrip('*'))

Examples of the above output results are as follows:

     this is string example....wow!!!
*****this is string example....wow!!!

Python3 string Python3 string