how to use String.strip()

来源:互联网 发布:学生平板电脑推荐知乎 编辑:程序博客网 时间:2024/05/01 01:02

Description

The method strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string (default whitespace characters).

Syntax

Following is the syntax for strip() method

str.strip([chars]);

Parameters

  • chars -- The characters to be removed from beginning or end of the string.

Return Value

This method returns a copy of the string in which all chars have been stripped from the beginning and the end of the string.

Example

The following example shows the usage of strip() method.

#!/usr/bin/pythonstr = "0000000this is string example....wow!!!0000000";print str.strip( '0' );

Let us compile and run the above program, this will produce the following result:

this is string example....wow!!!reference:http://www.tutorialspoint.com/python/string_strip.htm