@@ -552,7 +552,7 @@ Standard C. The recognized escape sequences are:
552
552
+-----------------+---------------------------------+-------+
553
553
| Escape Sequence | Meaning | Notes |
554
554
+=================+=================================+=======+
555
- | ``\newline `` | Backslash and newline ignored | |
555
+ | ``\ `` \ <newline> | Backslash and newline ignored | \( 1) |
556
556
+-----------------+---------------------------------+-------+
557
557
| ``\\ `` | Backslash (``\ ``) | |
558
558
+-----------------+---------------------------------+-------+
@@ -574,48 +574,58 @@ Standard C. The recognized escape sequences are:
574
574
+-----------------+---------------------------------+-------+
575
575
| ``\v `` | ASCII Vertical Tab (VT) | |
576
576
+-----------------+---------------------------------+-------+
577
- | ``\ooo `` | Character with octal value | (1,3 ) |
577
+ | ``\ooo `` | Character with octal value | (2,4 ) |
578
578
| | *ooo * | |
579
579
+-----------------+---------------------------------+-------+
580
- | ``\xhh `` | Character with hex value *hh * | (2,3 ) |
580
+ | ``\xhh `` | Character with hex value *hh * | (3,4 ) |
581
581
+-----------------+---------------------------------+-------+
582
582
583
583
Escape sequences only recognized in string literals are:
584
584
585
585
+-----------------+---------------------------------+-------+
586
586
| Escape Sequence | Meaning | Notes |
587
587
+=================+=================================+=======+
588
- | ``\N{name} `` | Character named *name * in the | \( 4 ) |
588
+ | ``\N{name} `` | Character named *name * in the | \( 5 ) |
589
589
| | Unicode database | |
590
590
+-----------------+---------------------------------+-------+
591
- | ``\uxxxx `` | Character with 16-bit hex value | \( 5 ) |
591
+ | ``\uxxxx `` | Character with 16-bit hex value | \( 6 ) |
592
592
| | *xxxx * | |
593
593
+-----------------+---------------------------------+-------+
594
- | ``\Uxxxxxxxx `` | Character with 32-bit hex value | \( 6 ) |
594
+ | ``\Uxxxxxxxx `` | Character with 32-bit hex value | \( 7 ) |
595
595
| | *xxxxxxxx * | |
596
596
+-----------------+---------------------------------+-------+
597
597
598
598
Notes:
599
599
600
600
(1)
601
- As in Standard C, up to three octal digits are accepted.
601
+ A backslash can be added at the end of a line to ignore the newline::
602
+
603
+ >>> 'This string will not include \
604
+ ... backslashes or newline characters.'
605
+ 'This string will not include backslashes or newline characters.'
606
+
607
+ The same result can be achieved using :ref: `triple-quoted strings <strings >`,
608
+ or parentheses and :ref: `string literal concatenation <string-concatenation >`.
602
609
603
610
(2)
604
- Unlike in Standard C, exactly two hex digits are required .
611
+ As in Standard C, up to three octal digits are accepted .
605
612
606
613
(3)
614
+ Unlike in Standard C, exactly two hex digits are required.
615
+
616
+ (4)
607
617
In a bytes literal, hexadecimal and octal escapes denote the byte with the
608
618
given value. In a string literal, these escapes denote a Unicode character
609
619
with the given value.
610
620
611
- (4 )
621
+ (5 )
612
622
.. versionchanged :: 3.3
613
623
Support for name aliases [# ]_ has been added.
614
624
615
- (5 )
625
+ (6 )
616
626
Exactly four hex digits are required.
617
627
618
- (6 )
628
+ (7 )
619
629
Any Unicode character can be encoded this way. Exactly eight hex digits
620
630
are required.
621
631
0 commit comments