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:
xxxxxxxxxx
1
text = "Hello\tWorld!"
2
3
print(text) # Hello World!
In this example, we escape double quotation marks to create a quote inside the text
string.
xxxxxxxxxx
1
text = "\"This is my quote.\""
2
3
print(text) # "This is my quote."
Output:
xxxxxxxxxx
1
"This is my quote."
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 |