This article describes how to use the rstrip () method to operate strings in Python. it is a basic knowledge in Python. For more information, see rstrip () returns a copy of the ending string of all characters removed from the string (space character by default.
Syntax
The syntax of the rstrip () method is as follows:
Str. rstrip ([chars])
Parameters
- Chars -- can provide characters to be removed.
Return value
All characters returned by this method are removed from the string (default: Space character) to end the string copy.
Example
The following example shows how to use the rstrip () method.
#! /Usr/bin/pythonstr = "this is string example... wow !!! "; Print str. rstrip (); str =" 88888888 this is string example... wow !!! 8888888 "; print str. rstrip ('8 ');
When we run the above program, it will produce the following results:
This is string example... wow !!! 88888888 this is string example... wow !!!