Escape characters are characters that are generally used to perform certain tasks and their usage in code directs the compiler to take a suitable action mapped to that character.
'\n' --> Leaves a line '\t' --> Leaves a space
The string after resolving escape character is : I Love Geeksforgeeks
But in certain cases it is desired not to resolve escapes, i.e the entire unresolved string has
to be printed. These are achieved by following ways.
This function returns a string in its printable format, i.e doesn’t resolve the escape sequences.
The string without repr() is : I Love Geeksforgeeks The string after using repr() is : 'I\nLove\tGeeksforgeeks'
Adding “r” or “R” to the target string triggers a repr() to the string internally and stops from the resolution of escape characters.
The string without r/R is : I Love Geeksforgeeks The string after using r is : I\nLove\tGeeksforgeeks The string after using R is : I\nLove\tGeeksforgeeks
- How to write an empty function in Python - pass statement?
- Operator Functions in Python | Set 2
- Find the first non-repeating character from a stream of characters
- Rearrange a string so that all same characters become d distance away
- Time Functions in Python | Set-2 (Date Manipulations)
- Send mail from your Gmail account using Python
- Python – The new generation Language
- Print Single and Multiple variable in Python
- Increment and Decrement Operators in Python
- str() vs repr() in Python
- Swap two variables in one line in C/C++, Python, PHP and Java
- Generate all permutation of a set in Python
- Class or Static Variables in Python
- trunc() in Python
- Division Operators in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.