{"id":13780,"date":"2022-01-11T11:31:48","date_gmt":"2022-01-11T11:31:48","guid":{"rendered":"https:\/\/linuxways.net\/?p=13780"},"modified":"2022-01-11T11:31:48","modified_gmt":"2022-01-11T11:31:48","slug":"strip-function-in-python","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/scripting\/strip-function-in-python\/","title":{"rendered":"Strip() Function in Python"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>strip() is a built-in Python function used to strip the string of the characters specified in the argument and print out the string without the specified characters.<\/p>\n<p>It&#8217;s a useful tool to quickly remove unwanted characters from a string or text. Here&#8217;s a smart way for users to do it. Now we will start introducing you to using the strip() function in Python. Hope you understand.<\/p>\n<h2>Example<\/h2>\n<pre>str = \",,,,,,....cat...,,,\"\r\n\r\nx = str.strip(\",.\")\r\n\r\nprint(x)<\/pre>\n<p>Output:<\/p>\n<p><strong>cat<\/strong><\/p>\n<h2>Definition<\/h2>\n<p>The strip() function prints out the string identical to the original and removes the characters specified in the argument.<\/p>\n<h2>The syntax<\/h2>\n<p>string.strip(characters)<\/p>\n<p><strong>Parameter Values:<\/strong><\/p>\n<p>characters: the character you want to delete<\/p>\n<h2>More examples<\/h2>\n<p><strong>Example 1<\/strong>: delete space characters<\/p>\n<pre>str = \" cat \"\r\n\r\nx = str.strip()\r\n\r\nprint(x)<\/pre>\n<p>Output:<\/p>\n<p><strong>cat<\/strong><\/p>\n<p><strong>Example 2<\/strong>:<\/p>\n<pre># Don't use strip()\r\n\r\nstr1 = \"Linux for people\"\r\n\r\nprint(str1)\r\n\r\n# Use strip()\r\n\r\nstr2 = \"for people\"\r\n\r\nprint(str1.strip(str2))<\/pre>\n<p>Output:<\/p>\n<p><strong>Linux for people<\/strong><\/p>\n<p><strong>Linux<\/strong><\/p>\n<h2>Conclusion<\/h2>\n<p>We introduced you to using the strip() function in Python.<\/p>\n<p>Thank you for reading!<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction strip() is a built-in Python function used to strip the string of the characters specified in the argument and print out the string without the specified characters.&hellip;<\/p>","protected":false},"author":1,"featured_media":13833,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[168],"tags":[10,835],"class_list":["post-13780","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-python","tag-strip-function"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=13780"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13780\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/13833"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=13780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=13780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=13780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}