but not with "'b'" or "'u'", therefore raw formatted strings are possible, but formatted bytes literals are not. In triple-quoted literals, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the literal. (A “quote” is the character used to open the literal, i.e. either "'" or """.) Unless an "'r'" or "'R'" prefix is present, escape sequences in string and bytes literals are interpreted according to rules similar to those used by Standard C. The recognized escape sequences are: +-------------------+-----------------------------------+---------+ | Escape Sequence | Meaning | Notes | |===================|===================================|=========| | "\newline" | Backslash and newline ignored | | +-------------------+-----------------------------------+---------+ | "\\" | 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) | | +-------------------+-----------------------------------+---------+ | "\t" | 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) | +-------------------+-----------------------------------+---------+ Escape sequences only recognized in string literals are: +-------------------+-----------------------------------+---------+ | Escape Sequence | Meaning | Notes | |===================|===================================|=========| | "\N{name}" | Character named *name* in the | (4) | | | Unicode database | | +-------------------+-----------------------------------+---------+ | "\uxxxx" | Character with 16-bit hex value | (5) | | | *xxxx* | | +-------------------+-----------------------------------+---------+ | "\Uxxxxxxxx" | Character with 32-bit hex value | (6) | | | *xxxxxxxx* | | +-------------------+-----------------------------------+---------+ Notes: 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. 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. u