Ways to print escape characters in Python
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