The Python Language Reference, Release 3.9.5 2.4. Literals 11 1 https://www.unicode.org/Public/11.0.0/ucd/NameAliases.txt Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left in the result . (This behavior is useful when debugging: if an escape sequence is mistyped, the resulting output is more easily recognized as broken.) It is also important to note that the escape sequences only recognized in string literals fall into the category of unrecognized escapes for bytes literals. Changed in version 3.6: Unrecognized escape sequences produce a$_{DeprecationWarning}$ . In a future Python version they will be a$_{SyntaxWarning}$and eventually a$_{SyntaxError}$. Even in a raw literal, quotes can be escaped with a backslash, but the backslash remains in the result; for example, r""" is a valid string literal consisting of two characters: a backslash and a double quote;$_{r""}$ is not a valid string literal (even a raw string cannot end in an odd number of backslashes). Specifically, a raw literal cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backslash followed by a newline is interpreted as those two characters as part of the literal, not as a line continuation. Notes: Escape sequences only recognized in string literals are: (1) As in Standard C, up to three octal digits are accepted. (2) Unlike in Standard C, exactly two hex digits are required. (3) In a bytes literal, hexadecimal and octal escapes denote the byte with the given value. In a string literal, these escapes denote a Unicode character with the given value. (4) Changed in version 3.3: Support for name aliases 1 has been added. (5) Exactly four hex digits are required. (6) Any Unicode character can be encoded this way. Exactly eight hex digits are required. Escape Sequence Meaning Notes \N{name} Character named name in the Unicode database (4) \uxxxx Character with 16-bit hex value xxxx (5) \Uxxxxxxxx Character with 32-bit hex value xxxxxxxx (6) Escape Sequence Meaning Notes 
ewline Backslash and newline ignored \\ Backslash ($_{\}$) \' Single quote ( ' ) " Double quote ( " ) \a ASCII Bell (BEL) \b ASCII Backspace (BS) \f ASCII Formfeed (FF) ASCII Linefeed (LF) \r ASCII Carriage Return (CR) ASCII Horizontal Tab (TAB) \v ASCII Vertical Tab (VT) \ooo Character with octal value ooo (1,3) \xhh Character with hex value hh (2,3)