{"id":10255,"date":"2021-03-31T13:26:31","date_gmt":"2021-03-31T07:56:31","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/?p=10255"},"modified":"2024-01-03T13:23:40","modified_gmt":"2024-01-03T07:53:40","slug":"carriage-return-python","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/","title":{"rendered":"Working With Carriage Return (\\r) in Python"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#Introduction\" title=\"Introduction\">Introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#What_is_a_carriage_return_r_in_Python\" title=\"What is a carriage return (\\r) in Python?\">What is a carriage return (\\r) in Python?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#Ways_to_use_carriage_return\" title=\"Ways to use carriage return\">Ways to use carriage return<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#1_Using_only_carriage_return_in_Python\" title=\"1. Using only carriage return in Python\">1. Using only carriage return in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#2_Using_carriage_return_in_Python_with_a_newline_character\" title=\"2. Using carriage return in Python with a newline character\">2. Using carriage return in Python with a newline character<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#3_Using_Carriage_return_in_Python_with_tab_space\" title=\"3. Using Carriage return in Python with tab space\">3. Using Carriage return in Python with tab space<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#4_Using_carriage_return_in_Python_tab_space_and_newline_character\" title=\"4. Using carriage return in Python, tab space, and newline character\">4. Using carriage return in Python, tab space, and newline character<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#How_r_and_n_is_handled_on_Linux_and_windows\" title=\"How \\r and \\n is handled on Linux and windows\">How \\r and \\n is handled on Linux and windows<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#Must_Read\" title=\"Must Read\">Must Read<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-introduction\"><span class=\"ez-toc-section\" id=\"Introduction\"><\/span>Introduction<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, <strong>we occur in a situation where we want to return to the starting point of the same line.<\/strong> In this article will help you understand the concept of carriage return in Python or <strong>\\r<\/strong> in Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-a-carriage-return-r-in-python\"><span class=\"ez-toc-section\" id=\"What_is_a_carriage_return_r_in_Python\"><\/span>What is a carriage return (\\r) in Python?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>It helps us move the cursor at the beginning of the line without moving it to the new line.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-ways-to-use-carriage-return\"><span class=\"ez-toc-section\" id=\"Ways_to_use_carriage_return\"><\/span>Ways to use carriage return<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We will show all the types by which we can use the &#8216;\\r&#8217; in Python. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-using-only-carriage-return-in-python\"><span class=\"ez-toc-section\" id=\"1_Using_only_carriage_return_in_Python\"><\/span>1. Using only carriage return in Python<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In this example, we will be using only the carriage return in the program in between the strings.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstring = 'My website is Latracal \\rSolution'\n\nprint(string)\n<\/pre><\/div>\n\n\n<p class=\"has-medium-font-size\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Solutionte is Latracal<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul>\n<li>Firstly, we have taken an input string as a string.<\/li>\n\n\n\n<li>we have applied \\r in between the string.<\/li>\n\n\n\n<li>\\r has shifted the cursor to the start, and &#8216;solution&#8217; contains 8 letters. From the beginning, 8 letters will be erased, and in place, that solution gets printed.<\/li>\n\n\n\n<li>You can see the output for better understanding.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-using-carriage-return-in-python-with-a-newline-character\"><span class=\"ez-toc-section\" id=\"2_Using_carriage_return_in_Python_with_a_newline_character\"><\/span>2. Using carriage return in Python with a newline character<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In this example, we will use &#8216;\\r&#8217; with the new line character(\\n) in the string program.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstring = 'My website is Latracal \\r\\nSolution'\nprint(string)\n\nstring = 'My website is Latracal \\n\\rSolution'\nprint(string)\nstring = 'My web\\nsite is Latracal \\rSolution'\n\nprint(string)\n<\/pre><\/div>\n\n\n<p class=\"has-medium-font-size\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>My website is Latracal \nSolution\nMy website is Latracal \nSolution\nMy web\nSolutionLatracal<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul>\n<li>Firstly, we have taken an input string as a string.<\/li>\n\n\n\n<li>Then, we have applied \\n and \\r in multiple places of the string.<\/li>\n\n\n\n<li>\\n is for newline.<\/li>\n\n\n\n<li>In the first two strings, we have put \\n before and after \\r. so the output gets printed in a newline.<\/li>\n\n\n\n<li>In the last string, \\n is first after the &#8216;site is, &#8216;which contains 8 letters as solution, so they get replaced.<\/li>\n\n\n\n<li>Hence, you can see the output.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-using-carriage-return-in-python-with-tab-space\"><span class=\"ez-toc-section\" id=\"3_Using_Carriage_return_in_Python_with_tab_space\"><\/span>3. Using Carriage return in Python with tab space<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In this example, we will be using the carriage or \\r with the combination of tab space or \\t in the program between the string.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr = ('\\tLatracal \\rsolution')\nprint(str)\n<\/pre><\/div>\n\n\n<p class=\"has-medium-font-size\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>solutionLatracal <\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul>\n<li>Firstly, we have taken an input as str.<\/li>\n\n\n\n<li>Then, we applied tab space at the beginning of the string, giving 8 spaces at the beginning.<\/li>\n\n\n\n<li>Then, we have applied \\r. After \\r, there are 8 letters of solution.<\/li>\n\n\n\n<li>In the output, the letter of solution will fill the tab spaces as they are equal.<\/li>\n\n\n\n<li>You can see the output for better understanding.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-4-using-carriage-return-in-python-tab-space-and-newline-character\"><span class=\"ez-toc-section\" id=\"4_Using_carriage_return_in_Python_tab_space_and_newline_character\"><\/span>4. Using carriage return in Python, tab space, and newline character<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In this example, we will be mixing all the characters, such as carriage return(\\r), tab space(\\t), and newline character(\\n) in the given string, and see the output so that we can understand the use to \\r more clearly.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr = ('\\tlatracal\\rsolution\\n\\tis a\\rwebsite\\n')\nprint(str)\n<\/pre><\/div>\n\n\n<p class=\"has-medium-font-size\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>solutionlatracal\nwebsite is a<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul>\n<li>Firstly, we have taken an input string as str.<\/li>\n\n\n\n<li>Then, we applied all the characters like \\t for tab space, \\n for the new line, and \\r for carriage return.<\/li>\n\n\n\n<li>Hence, you can see the output. <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-r-and-n-is-handled-on-linux-and-windows\"><span class=\"ez-toc-section\" id=\"How_r_and_n_is_handled_on_Linux_and_windows\"><\/span>How \\r and \\n is handled on Linux and windows<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>As we all know, we use \\r for carriage return and \\n for newline in Windows. But, for different operating systems, there are different conventions. The difference is simple, i.e., OS designers had to choose how we should represent a new line in text in computer files. For some reason, in Unix\/Linux world, a single LF(Line feed) was chosen as the new line marker. MS-DOS chose CR+LF, and Windows inherited \\n as a new line. Thus, we got to know that different platforms have different conventions.<\/p>\n\n\n\n<p>In practice, this is becoming a shorter of a problem. The newline marker is relevant for the programs that process &#8220;plain text,&#8221; and there are not many. This mostly only affects program source code, configuration files, and some simple text files with <a href=\"https:\/\/docs.python.org\/3\/\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a>. As in today&#8217;s world, most programs handling these kinds of files (editors, compilers, etc.) can handle both <a href=\"https:\/\/www.pythonpool.com\/python-remove-newline-from-list\/\" target=\"_blank\" rel=\"noopener\">newline<\/a> conventions, so it does not matter which one you choose.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-red-color has-text-color\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links\"><li><a href=\"https:\/\/www.pythonpool.com\/python-print-without-newline\/\">Python Print Without Newline [How to, Examples, Tutorial]<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-print-blank-line\/\">Multiple Ways To Print Blank Line in Python<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-is-not-recognized-as-an-internal-or-external-command\/\">Python is Not Recognized as an Internal or External Command<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-remove-last-character-from-string\/\">5 Ways to Remove the Last Character From String in Python<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this tutorial, we have learned about the concept of carriage return (&#8216;\\r&#8217;) with its definition. I also understood all the ways through which we can use &#8216;\\r&#8217; in- different ways in detail with the help of an example. All the examples are explained in detail.<\/p>\n\n\n\n<p>However, please let me know in the comment section below if you have any questions. I will try to help you as soon as possible. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Sometimes, we occur in a situation where we want to return to the starting point of the same line. In this article will help &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Working With Carriage Return (\\r) in Python\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/carriage-return-python\/#more-10255\" aria-label=\"More on Working With Carriage Return (\\r) in Python\">Read more<\/a><\/p>\n","protected":false},"author":17,"featured_media":10370,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[3803,3801,3799,3800],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Working With Carriage Return (\\r) in Python - Python Pool<\/title>\n<meta name=\"description\" content=\"Carriage return in Python (&#039;r&#039;) helps us to move the cursor at the beginning of the line without moving the cursor to the new line.\" \/>\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.pythonpool.com\/carriage-return-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working With Carriage Return (\\r) in Python\" \/>\n<meta property=\"og:description\" content=\"Introduction Sometimes, we occur in a situation where we want to return to the starting point of the same line. In this article will help you understand\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/carriage-return-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-31T07:56:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-03T07:53:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Siddharth Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Siddharth Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/\"},\"author\":{\"name\":\"Siddharth Jain\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa\"},\"headline\":\"Working With Carriage Return (\\\\r) in Python\",\"datePublished\":\"2021-03-31T07:56:31+00:00\",\"dateModified\":\"2024-01-03T07:53:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/\"},\"wordCount\":741,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg\",\"keywords\":[\"python \\\\r\",\"python carriage return\",\"python print carriage return\",\"python strip carriage return\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/carriage-return-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/\",\"name\":\"Working With Carriage Return (\\\\r) in Python - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg\",\"datePublished\":\"2021-03-31T07:56:31+00:00\",\"dateModified\":\"2024-01-03T07:53:40+00:00\",\"description\":\"Carriage return in Python ('\\\\r') helps us to move the cursor at the beginning of the line without moving the cursor to the new line.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/carriage-return-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg\",\"width\":1350,\"height\":650,\"caption\":\"Carriage Return Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/carriage-return-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Working With Carriage Return (\\\\r) in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa\",\"name\":\"Siddharth Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/46e774729027d25817fb19483e28dd4a?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/46e774729027d25817fb19483e28dd4a?s=96&d=wavatar&r=g\",\"caption\":\"Siddharth Jain\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Working With Carriage Return (\\r) in Python - Python Pool","description":"Carriage return in Python ('r') helps us to move the cursor at the beginning of the line without moving the cursor to the new line.","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:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/","og_locale":"en_US","og_type":"article","og_title":"Working With Carriage Return (\\r) in Python","og_description":"Introduction Sometimes, we occur in a situation where we want to return to the starting point of the same line. In this article will help you understand","og_url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/","og_site_name":"Python Pool","article_published_time":"2021-03-31T07:56:31+00:00","article_modified_time":"2024-01-03T07:53:40+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg","type":"image\/jpeg"}],"author":"Siddharth Jain","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Siddharth Jain","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/"},"author":{"name":"Siddharth Jain","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa"},"headline":"Working With Carriage Return (\\r) in Python","datePublished":"2021-03-31T07:56:31+00:00","dateModified":"2024-01-03T07:53:40+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/"},"wordCount":741,"commentCount":3,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg","keywords":["python \\r","python carriage return","python print carriage return","python strip carriage return"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/","url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/","name":"Working With Carriage Return (\\r) in Python - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg","datePublished":"2021-03-31T07:56:31+00:00","dateModified":"2024-01-03T07:53:40+00:00","description":"Carriage return in Python ('\\r') helps us to move the cursor at the beginning of the line without moving the cursor to the new line.","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg","contentUrl":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/03\/Carriage-Return-Python.jpg","width":1350,"height":650,"caption":"Carriage Return Python"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/carriage-return-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Working With Carriage Return (\\r) in Python"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#\/schema\/person\/75a3240fabe5ea90200777a9d8d3b4fa","name":"Siddharth Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/secure.gravatar.com\/avatar\/46e774729027d25817fb19483e28dd4a?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/secure.gravatar.com\/avatar\/46e774729027d25817fb19483e28dd4a?s=96&d=wavatar&r=g","caption":"Siddharth Jain"}}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/10255"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=10255"}],"version-history":[{"count":14,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/10255\/revisions"}],"predecessor-version":[{"id":31934,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/10255\/revisions\/31934"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/10370"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=10255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=10255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=10255"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926035753\/https:\/\/api.w.org\/{rel}","templated":true}]}}