Latest web development tutorials

Python rstrip () method

Python strings Python strings


description

Python 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/python

str = "     this is string example....wow!!!     ";
print str.rstrip();
str = "88888888this is string example....wow!!!8888888";
print str.rstrip('8');

Examples of the above output results are as follows:

     this is string example....wow!!!
88888888this is string example....wow!!!

Python strings Python strings