How to delete the specified character at the end of a string by python
In this article Xiaobian introduces in detail "python how to delete the specified character at the end of the string", the content is detailed, the steps are clear, and the details are handled properly. I hope that this "python how to delete the specified character at the end of the string" article can help you solve your doubts, following the editor's train of thought slowly in-depth, together to learn new knowledge.
Specific steps for use:
1. First open the python editor and create a new python project.
2. Use the rstrip method in the python project to delete the specified character at the end of the delete string.
Print str.rstrip ('8'); # Delete characters with "8" at the end of the string
Sample code:
#! / usr/bin/python
Str = "this is string example.wowning examples!"
Print str.rstrip ()
Str = "88888888this is string example.wowning examples 8888888"
Print str.rstrip ('8')
Output result:
This is string example....wow!!!
88888888this is string example....wow!!!
Read this, the "python how to delete the end of the string specified characters" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow the industry information channel.