{"id":17605,"date":"2021-08-06T13:02:41","date_gmt":"2021-08-06T07:32:41","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=17605"},"modified":"2021-08-06T13:02:46","modified_gmt":"2021-08-06T07:32:46","slug":"remove-all-spaces-from-string-python-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/","title":{"rendered":"Remove all spaces from string Python | Example code"},"content":{"rendered":"\n<p>There are many ways to remove space in Python. Some methods to remove all spaces from string Python are:-<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>replace()<\/li><li>split() and join()<\/li><li>regex (Regular expression )<\/li><li>translate()<\/li><\/ul>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Note<\/strong>: Python String strip() function will remove only leading and trailing whitespace, not between wrods.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Remove all spaces from string Python Example<\/strong><\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using replace() method<\/strong><\/h3>\n\n\n\n<p>This function will remove whitespaces between words too.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>test_str = \"Python code to remove whitespace\"\r\n\r\nprint(test_str.replace(\" \", \"\"))\r\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"378\" height=\"143\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg?resize=378%2C143&#038;ssl=1\" alt=\"Remove all spaces from string Python\" class=\"wp-image-17649\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using split() and join() method<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>test_str = \"Python code to remove whitespace\"\r\n\r\nprint(\"\".join(test_str.split()))\r\n<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span style=\"font-size: revert; color: initial;\"><strong>Regular expression<\/strong><\/span> <\/h3>\n\n\n\n<p>For this example, you have to <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-modules-import-custom-builtin-package\/\">import <\/a>the <strong>&#8220;re&#8221;<\/strong> <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-modules-import-custom-builtin-package\/\">module<\/a>. Try a regex with <code>re.sub<\/code>. You can search for all whitespace and replace it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import re\r\n\r\ntest_str = \"Python code to remove whitespace\"\r\npattern = re.compile(r'\\s+')\r\n\r\nprint(re.sub(pattern, '', test_str))\r\n<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using <span style=\"font-size: revert; color: initial;\">translate()<\/span> method<\/strong><\/h3>\n\n\n\n<p>Get rid of all the whitespaces using the string translate() function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import string\r\n\r\ntest_str = \"Python code to remove whitespace\"\r\n\r\nprint(test_str.translate(test_str.maketrans('', '', ' \\n\\t\\r')))\r\n<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How to strip all whitespace from a string?<\/strong><\/h3>\n\n\n\n<p>For example, want a string like <strong>&#8220;strip my spaces&#8221;<\/strong> to be turned into <strong>&#8220;stripmyspaces&#8221;<\/strong>, but I cannot seem to accomplish that with a <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-trim-string-python-string-strip-function\/\">strip()<\/a>:<\/p>\n\n\n\n<p>Use replace method If you just want to remove spaces instead of all whitespace:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>test_str = \"strip my spaces\"\r\n\r\nprint(test_str.replace(\" \", \"\"))\r\n<\/code><\/pre>\n\n\n\n<p>Alternatively, use a regular expression:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import re\r\n\r\ntest_str = \"strip my spaces\"\r\n\r\nprint(re.sub(r\"\\s\", \"\", test_str))\r\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: stripmyspaces<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have doubts and suggestions on this Python string topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>There are many ways to remove space in Python. Some methods to remove all spaces from string Python are:- replace() split() and join() regex (Regular expression ) translate() Note: Python String strip() function will remove only leading and trailing whitespace, not between wrods. Remove all spaces from string Python Example Simple example code. Using replace()&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Remove all spaces from string Python | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[136,98],"post_series":[],"class_list":["post-17605","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-code","tag-python-string"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Remove all spaces from string Python | Example code - EyeHunts<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Remove all spaces from string Python | Example code - EyeHunts\" \/>\n<meta property=\"og:description\" content=\"There are many ways to remove space in Python. Some methods to remove all spaces from string Python are:- replace() split() and join() regex (Regular expression ) translate() Note: Python String strip() function will remove only leading and trailing whitespace, not between wrods. Remove all spaces from string Python Example Simple example code. Using replace()&hellip;&nbsp;Read More &raquo;Remove all spaces from string Python | Example code\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-06T07:32:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-06T07:32:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/\",\"name\":\"Remove all spaces from string Python | Example code - EyeHunts\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg\",\"datePublished\":\"2021-08-06T07:32:41+00:00\",\"dateModified\":\"2021-08-06T07:32:46+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg?fit=378%2C143&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg?fit=378%2C143&ssl=1\",\"width\":378,\"height\":143},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Remove all spaces from string Python | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Remove all spaces from string Python | Example code - EyeHunts","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Remove all spaces from string Python | Example code - EyeHunts","og_description":"There are many ways to remove space in Python. Some methods to remove all spaces from string Python are:- replace() split() and join() regex (Regular expression ) translate() Note: Python String strip() function will remove only leading and trailing whitespace, not between wrods. Remove all spaces from string Python Example Simple example code. Using replace()&hellip;&nbsp;Read More &raquo;Remove all spaces from string Python | Example code","og_url":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-08-06T07:32:41+00:00","article_modified_time":"2021-08-06T07:32:46+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/","name":"Remove all spaces from string Python | Example code - EyeHunts","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg","datePublished":"2021-08-06T07:32:41+00:00","dateModified":"2021-08-06T07:32:46+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg?fit=378%2C143&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-all-spaces-from-string-Python.jpg?fit=378%2C143&ssl=1","width":378,"height":143},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/remove-all-spaces-from-string-python-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Remove all spaces from string Python | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":17610,"url":"https:\/\/tutorial.eyehunts.com\/python\/remove-leading-and-trailing-spaces-in-python-example-code\/","url_meta":{"origin":17605,"position":0},"title":"Remove leading and trailing spaces in Python | Example code","author":"Rohit","date":"August 6, 2021","format":false,"excerpt":"Use the strip() method to remove trailing and leading spaces in Python. It will not remove internal spaces in a string. Remove leading and trailing spaces in Python Example Simple example code eliminates all whitespace before the first character and after the last character in the string. It will actually\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-leading-and-trailing-spaces-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17574,"url":"https:\/\/tutorial.eyehunts.com\/python\/remove-multiple-spaces-from-string-python-example-code\/","url_meta":{"origin":17605,"position":1},"title":"Remove multiple spaces from string Python | Example code","author":"Rohit","date":"August 5, 2021","format":false,"excerpt":"You can remove more than 1 space (Unwanted space) between intermediate words in strings using re.sub() or split() + join() method. Example remove multiple spaces from string Python Simple example code. Using re.sub() Using the regex will unwanted space between the words to be just a single space using the\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Remove multiple spaces from string Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Remove-multiple-spaces-from-string-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17603,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-remove-extra-spaces-between-words-example-code\/","url_meta":{"origin":17605,"position":2},"title":"Python remove extra spaces between words | Example code","author":"Rohit","date":"August 6, 2021","format":false,"excerpt":"Using re.sub() or split() + join() method to remove extra spaces between words in Python. Python remove extra spaces between words Example Simple example code. Using re.sub() Regular expressions need to import the re module. It will replace any number of spaces with a single space: import re string1 =\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python remove extra spaces between words","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Python-remove-extra-spaces-between-words.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17572,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-strip-multiple-characters-python-example-code\/","url_meta":{"origin":17605,"position":3},"title":"How to strip multiple characters Python | Example code","author":"Rohit","date":"August 7, 2021","format":false,"excerpt":"Python provides a special 3 methods to remove whitespace from a string (characters) lstrip() - Remove spaces to the left of the stringrstrip() - Remove spaces to the right of the stringstrip() - Remove spaces at the beginning and at the end of the string. There are 2 more methods\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"strip multiple characters Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/strip-multiple-characters-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8197,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-trim-string-python-string-strip-function\/","url_meta":{"origin":17605,"position":4},"title":"Python trim string | Python string strip() function","author":"Rohit","date":"April 24, 2020","format":false,"excerpt":"You can trim string in python using a strip() function. It removes the leading and trailing spaces of a given String. There are 2 more methods \"lstrip() and rstrip()\" that can use to remove leading or trailing whitespaces. Note: default whitespace characters will remove, you can remove other char also.\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-trim-string-string-strip-function-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-trim-string-string-strip-function-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-trim-string-string-strip-function-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-trim-string-string-strip-function-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8211,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-rstrip-function-trim-string-from-right\/","url_meta":{"origin":17605,"position":5},"title":"Python rstrip Function | trim string from right","author":"Rohit","date":"April 26, 2020","format":false,"excerpt":"Python rstrip function is used to remove trailing characters (characters at the end of a string). Whitespace is the default trailing character to remove if no character is passed as a parameter. If you want to remove (trim string):- All leading White-space - use Python lstrip Function.Leading and trailing spaces-\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-rstrip-Function-trim-string-from-right.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-rstrip-Function-trim-string-from-right.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-rstrip-Function-trim-string-from-right.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-rstrip-Function-trim-string-from-right.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-rstrip-Function-trim-string-from-right.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/17605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=17605"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/17605\/revisions"}],"predecessor-version":[{"id":17654,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/17605\/revisions\/17654"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=17605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=17605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=17605"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=17605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}