Python supports escape characters that are non-printable and can be represented with a backslash notation. An escape character gets interpreted in both single and double quoted strings:
Notations |
Hex characters |
Description |
a |
0x07 |
Bell or alert |
b |
0x08 |
Backspace |
cx |
Control-x |
|
n |
0x0a |
Newline |
C-x |
Control-x |
|
e |
0x1b |
Escape |
f |
0x0c |
Form feed |
s |
0x20 |
Space |
M-C-x |
Meta-control-x |
|
x |
Character x |
|
nnn |
Octal notation, where n is in the range 0.7 |
|
r |
0x0d |
Carriage return |
xnn |
Hexadecimal notation, where n is in the range 0.9, a.f, or A.F |
|
t |
0x09 |
Tab |
v |
0x0b |
Vertical tab |