{"id":15722,"date":"2024-06-20T21:18:47","date_gmt":"2024-06-20T17:48:47","guid":{"rendered":"https:\/\/www.itpiran.net\/blog\/?p=15722"},"modified":"2024-06-20T21:18:47","modified_gmt":"2024-06-20T17:48:47","slug":"python-remove-character-from-string","status":"publish","type":"post","link":"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/python-remove-character-from-string\/","title":{"rendered":"How to remove characters from a string in Python"},"content":{"rendered":"<h2 id=\"%d9%85%d9%82%d8%af%d9%85%d9%87\">Introduction<\/h2>\n<p>This article describes two common methods you can use to remove characters from a string using Python:<\/p>\n<ul>\n<li>Method <code>String replace()<\/code><\/li>\n<li>Method <code>String translate()<\/code><\/li>\n<\/ul>\n<p>To learn a few different ways to remove spaces from a string in Python, see Removing Spaces from a String in Python.<\/p>\n<p>A Python string object is immutable, so you cannot change its value. Any method that manipulates a string value returns a new String object.<\/p>\n<p>The examples in this tutorial use the interactive Python console on the command line to demonstrate different ways to remove characters.<\/p>\n<h2 id=\"%d8%ad%d8%b0%d9%81-%da%a9%d8%a7%d8%b1%d8%a7%da%a9%d8%aa%d8%b1%d9%87%d8%a7-%d8%a7%d8%b2-%db%8c%da%a9-%d8%b1%d8%b4%d8%aa%d9%87-%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-%d9%85\">Removing characters from a string using the replace() method<\/h2>\n<p>The String() method replaces a character with a new character. You can remove a character from a string by providing the character(s) as the first argument and an empty string as the second argument.<\/p>\n<p>Declare the string variable:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'abc12321cba'<\/code><\/pre>\n<\/div>\n<p>Replace the character with an empty string:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.replace('a', ''))<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>Output\r\nbc12321cb<\/code><\/pre>\n<\/div>\n<p>The output shows that both occurrences of the character a have been removed from the string.<\/p>\n<h5 id=\"%d8%ad%d8%b0%d9%81-%da%a9%d8%a7%d8%b1%d8%a7%da%a9%d8%aa%d8%b1%d9%87%d8%a7%db%8c-newline-%d8%a7%d8%b2-%db%8c%da%a9-%d8%b1%d8%b4%d8%aa%d9%87-%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87\">Removing Newline Characters from a String Using the replace() Method<\/h5>\n<p>Declare a string variable with multiple newline characters:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'ab\\ncd\\nef' code... *\/<\/code><\/pre>\n<\/div>\n<p>Replace the newline character with an empty string:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.replace('\\n', ''))<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>Output\r\nabcdef<\/code><\/pre>\n<\/div>\n<p>The output shows that both newline characters (\\n) have been removed from the string.<\/p>\n<h5 id=\"%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-%d9%85%d8%aa%d8%af-replace-%db%8c%da%a9-%d8%b2%db%8c%d8%b1-%d8%b1%d8%b4%d8%aa%d9%87-%d8%b1%d8%a7-%d8%a7%d8%b2-%db%8c%da%a9-%d8%b1\">Remove a substring from a string using the replace() method<\/h5>\n<p>The replace() method takes strings as arguments, so you can replace a word in a string.<\/p>\n<p>Declare the string variable:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'Helloabc'<\/code><\/pre>\n<\/div>\n<p>Replace a word with an empty string:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.replace('Hello', ''))<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<p>The output shows that the string Hello has been removed from the input string.<\/p>\n<h5 id=\"%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-%d9%85%d8%aa%d8%af-replace-%d8%aa%d8%b9%d8%af%d8%a7%d8%af-%d8%af%d9%81%d8%b9%d8%a7%d8%aa-%d9%85%d8%b4%d8%ae%d8%b5%db%8c-%da%a9\">Remove characters a specified number of times using the replace() method<\/h5>\n<p>You can pass a third argument to the replace() method to specify the number of replacements to perform on the string before stopping. For example, if you specify 2 as the third argument, then only the first 2 occurrences of the given characters will be replaced.<\/p>\n<p>Declare the string variable:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'abababab'<\/code><\/pre>\n<\/div>\n<p>Replace the first two characters with the new character:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.replace('a', 'A', 2)) # perform replacement twice<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>Output\r\nAbAbabab<\/code><\/pre>\n<\/div>\n<p>The output shows that the first two occurrences of the character a have been replaced with the character A. Since the replacement was done only twice, the other occurrences of one remain in the string.<\/p>\n<h2 id=\"%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-%d9%85%d8%aa%d8%af-translate-%da%a9%d8%a7%d8%b1%d8%a7%da%a9%d8%aa%d8%b1%d9%87%d8%a7-%d8%b1%d8%a7-%d8%a7%d8%b2-%d8%b1%d8%b4%d8%aa\">Remove characters from a string using the translate() method<\/h2>\n<p>The Python string translate() method replaces each character in the string using a given mapping table or dictionary.<\/p>\n<p>Declare a string variable:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'abc12321cba'<\/code><\/pre>\n<\/div>\n<p>Get the Unicode code point value of a character and replace it with None:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.translate({ord('b'): None}))<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>Output\r\nac12321ca<\/code><\/pre>\n<\/div>\n<p>The output shows that both occurrences of the character b as defined in the custom dictionary have been removed from the string.<\/p>\n<h5 id=\"%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-%d9%85%d8%aa%d8%af-translate-%da%86%d9%86%d8%af%db%8c%d9%86-%da%a9%d8%a7%d8%b1%d8%a7%da%a9%d8%aa%d8%b1-%d8%b1%d8%a7-%d8%a7%d8%b2\">Remove multiple characters from a string using the translate() method<\/h5>\n<p>You can replace multiple characters in a string using the translate() method. The following example uses a custom dictionary, {ord(i): None for i in &#039;abc&#039;}, which replaces all occurrences of a, b, and c in the given string with None.<\/p>\n<p>Declare the string variable:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'abc12321cba'<\/code><\/pre>\n<\/div>\n<p>Replace all characters abc with None:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.translate({ord(i): None for i in 'abc'}))<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>Output\r\n12321<\/code><\/pre>\n<\/div>\n<p>The output shows that all occurrences of a, b, and c have been removed from the string as defined in the custom dictionary.<\/p>\n<h5 id=\"%d8%a8%d8%a7-%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-%d9%85%d8%aa%d8%af-translate-%da%a9%d8%a7%d8%b1%d8%a7%da%a9%d8%aa%d8%b1%d9%87%d8%a7%db%8c-newline-%d8%b1%d8%a7-%d8%a7%d8%b2\">Remove Newline Characters from a String Using the translate() Method<\/h5>\n<p>You can replace newline characters in a string using the translate() method. The following example uses a custom dictionary, {ord(&#039;\\n&#039;): None}, which replaces all occurrences of \\n in the given string with None.<\/p>\n<p>Declare the string variable:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>s = 'ab\\ncd\\nef'<\/code><\/pre>\n<\/div>\n<p>Replace all \\n characters with None:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>print(s.translate({ord('\\n'): None}))<\/code><\/pre>\n<\/div>\n<p>The output is:<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>Output\r\nabcdef<\/code><\/pre>\n<\/div>\n<p>The output shows that all occurrences of the newline character \\n have been removed from the string as defined in the custom dictionary.<\/p>\n<h2 id=\"%d9%86%d8%aa%db%8c%d8%ac%d9%87\">Result<\/h2>\n<p>In this tutorial, you learned the methods you can use to remove characters from strings in Python. Continue your learning about Python strings.<\/p>","protected":false},"excerpt":{"rendered":"Introduction This article describes two common methods you can use to remove characters\u2026","protected":false},"author":1,"featured_media":15724,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","_yoast_wpseo_canonical":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_opengraph-image":"","_yoast_wpseo_twitter-description":"","_yoast_wpseo_twitter-image":"","_yoast_wpseo_focuskeywords":"","_yoast_wpseo_primary_category":"193","footnotes":""},"categories":[193,363],"tags":[376,366],"class_list":{"0":"post-15722","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials","8":"category-programming","9":"tag-python","10":"tag-366"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran<\/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:\/\/www.itpiran.net\/blog\/en\/tutorials\/python-remove-character-from-string\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"og:description\" content=\"\u0645\u0642\u062f\u0645\u0647 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u062f\u0648 \u0631\u0648\u0634 \u0645\u062a\u062f\u0627\u0648\u0644 \u0631\u0627 \u0634\u0631\u062d \u0645\u06cc \u062f\u0647\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0622\u0646\u0647\u0627 \u0628\u0631\u0627\u06cc \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/python-remove-character-from-string\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-20T17:48:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.itpiran.net\/blog\/wp-content\/uploads\/2024\/06\/removestring.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1793\" \/>\n\t<meta property=\"og:image:height\" content=\"1110\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\"},\"headline\":\"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646\",\"datePublished\":\"2024-06-20T17:48:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/\"},\"wordCount\":45,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/removestring.jpg\",\"keywords\":[\"Python\",\"\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc\"],\"articleSection\":[\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/\",\"name\":\"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/removestring.jpg\",\"datePublished\":\"2024-06-20T17:48:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/removestring.jpg\",\"contentUrl\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/removestring.jpg\",\"width\":1793,\"height\":1110},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/python-remove-character-from-string\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/category\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"name\":\"\u0628\u0644\u0627\u06af ITPiran\",\"description\":\"\u0627\u062e\u0628\u0627\u0631 \u0648 \u0645\u0642\u0627\u0644\u0627\u062a \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\",\"name\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"alternateName\":\"ITPIran Blog\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"width\":512,\"height\":512,\"caption\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\",\"name\":\"admin\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/en\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to remove characters from a string in Python - ITPiran Blog","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:\/\/www.itpiran.net\/blog\/en\/tutorials\/python-remove-character-from-string\/","og_locale":"en_US","og_type":"article","og_title":"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran","og_description":"\u0645\u0642\u062f\u0645\u0647 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u062f\u0648 \u0631\u0648\u0634 \u0645\u062a\u062f\u0627\u0648\u0644 \u0631\u0627 \u0634\u0631\u062d \u0645\u06cc \u062f\u0647\u062f \u06a9\u0647 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0622\u0646\u0647\u0627 \u0628\u0631\u0627\u06cc \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627&hellip;","og_url":"https:\/\/www.itpiran.net\/blog\/en\/tutorials\/python-remove-character-from-string\/","og_site_name":"\u0628\u0644\u0627\u06af ITPiran","article_published_time":"2024-06-20T17:48:47+00:00","og_image":[{"width":1793,"height":1110,"url":"https:\/\/www.itpiran.net\/blog\/wp-content\/uploads\/2024\/06\/removestring.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#article","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/"},"author":{"name":"admin","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81"},"headline":"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646","datePublished":"2024-06-20T17:48:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/"},"wordCount":45,"commentCount":0,"publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#primaryimage"},"thumbnailUrl":"https:\/\/www.itpiran.net\/blog\/wp-content\/uploads\/2024\/06\/removestring.jpg","keywords":["Python","\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc"],"articleSection":["\u0622\u0645\u0648\u0632\u0634\u06cc","\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/","url":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/","name":"How to remove characters from a string in Python - ITPiran Blog","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#primaryimage"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#primaryimage"},"thumbnailUrl":"https:\/\/www.itpiran.net\/blog\/wp-content\/uploads\/2024\/06\/removestring.jpg","datePublished":"2024-06-20T17:48:47+00:00","breadcrumb":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#primaryimage","url":"https:\/\/www.itpiran.net\/blog\/wp-content\/uploads\/2024\/06\/removestring.jpg","contentUrl":"https:\/\/www.itpiran.net\/blog\/wp-content\/uploads\/2024\/06\/removestring.jpg","width":1793,"height":1110},{"@type":"BreadcrumbList","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/python-remove-character-from-string\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.itpiran.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u0622\u0645\u0648\u0632\u0634\u06cc","item":"https:\/\/www.itpiran.net\/blog\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"\u0646\u062d\u0648\u0647 \u062d\u0630\u0641 \u06a9\u0627\u0631\u0627\u06a9\u062a\u0631\u0647\u0627 \u0627\u0632 \u0631\u0634\u062a\u0647 \u062f\u0631 \u067e\u0627\u06cc\u062a\u0648\u0646"}]},{"@type":"WebSite","@id":"https:\/\/www.itpiran.net\/blog\/#website","url":"https:\/\/www.itpiran.net\/blog\/","name":"ITPiran Blog","description":"Iranian Sustainable Trade News and Articles","publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.itpiran.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.itpiran.net\/blog\/#organization","name":"Sustainable Iranian Business Blog","alternateName":"ITPIran Blog","url":"https:\/\/www.itpiran.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","contentUrl":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","width":512,"height":512,"caption":"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81","name":"admin","url":"https:\/\/www.itpiran.net\/blog\/en\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts\/15722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/comments?post=15722"}],"version-history":[{"count":1,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts\/15722\/revisions"}],"predecessor-version":[{"id":15723,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/posts\/15722\/revisions\/15723"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/media\/15724"}],"wp:attachment":[{"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/media?parent=15722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/categories?post=15722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/en\/wp-json\/wp\/v2\/tags?post=15722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}