{"id":24531,"date":"2021-10-21T10:04:41","date_gmt":"2021-10-21T04:34:41","guid":{"rendered":"https:\/\/python-programs.com\/?p=24531"},"modified":"2021-11-05T19:05:30","modified_gmt":"2021-11-05T13:35:30","slug":"python-string-strip-method-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-string-strip-method-examples\/","title":{"rendered":"Python String strip() Method Examples"},"content":{"rendered":"

In the previous article, we have discussed Python String rstrip() Method Examples<\/a>
\nstrip() Method in Python:<\/strong><\/p>\n

The strip() method removes any leading (at the start) and trailing (at the end) characters (space is the default leading character to remove)<\/p>\n

Syntax:<\/strong><\/p>\n

string.strip(characters)<\/pre>\n

Parameters<\/strong><\/p>\n

characters:<\/strong> This is optional. A set of characters that should be removed as leading\/trailing characters.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given first string = \"!!!!!!!_python-programs_!!!!!\"\r\nGiven characters = \"!\"<\/pre>\n

Output:<\/strong><\/p>\n

The above given first string is : !!!!!!!_python-programs_!!!!!\r\nThe given first string after applying strip() function: _python-programs_<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given second string = \"^^^^***btechgeeks^^^***\"\r\nGiven characters = \"^*\"<\/pre>\n

Output:<\/strong><\/p>\n

The above given second string is : ^^^^***btechgeeks^^^***\r\nThe given second string after applying strip() function: btechgeeks<\/pre>\n

String strip() Method Examples in Python<\/h2>\n