String literals can be enclosed in matching single quotes (') or double quotes ("). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings). The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter `r' or `R'; such strings are called raw strings and use different rules for backslash escape sequences.
Literals |
Meaning |
---|---|
\\ |
Backslash (\) |
\' |
Single quote(') |
\" |
Double quote(") |
\a |
ASCII Bell(BEL) |
\b |
ASCII Backspace(BS) |
\f |
ASCII Formfeed(FF) |
\n |
ASCII Linefeed(LF) |
\r |
ASCII Carriage Return(CR) |