EN
Python - escape characters
0
points
In this article, we would like to show you escape characters and how to insert them to the string in Python.
Quick solution:
text = "Hello\tWorld!"
print(text) # Hello World!
Practical example
In this example, we escape double quotation marks to create a quote inside the text
string.
text = "\"This is my quote.\""
print(text) # "This is my quote."
Output:
"This is my quote."
Escape characters
escape character | result |
---|---|
\' |
single quote |
\\ | backslash |
\n | new line |
\t |
tab |
\b | backspace |
\r | carriage return |
\f | form feed |
\ooo | octal value |
\xhh | hex value |