@@ -350,8 +350,9 @@ The meaning of the various alignment options is as follows:
350
350
| ``'=' `` | Forces the padding to be placed after the sign (if any) |
351
351
| | but before the digits. This is used for printing fields |
352
352
| | in the form '+000000120'. This alignment option is only |
353
- | | valid for numeric types. It becomes the default for |
354
- | | numbers when '0' immediately precedes the field width. |
353
+ | | valid for numeric types, excluding :class: `complex `. |
354
+ | | It becomes the default for numbers when '0' immediately |
355
+ | | precedes the field width. |
355
356
+---------+----------------------------------------------------------+
356
357
| ``'^' `` | Forces the field to be centered within the available |
357
358
| | space. |
@@ -432,9 +433,9 @@ including any prefixes, separators, and other formatting characters.
432
433
If not specified, then the field width will be determined by the content.
433
434
434
435
When no explicit alignment is given, preceding the *width * field by a zero
435
- (``'0' ``) character enables
436
- sign-aware zero-padding for numeric types . This is equivalent to a *fill *
437
- character of ``'0' `` with an *alignment * type of ``'=' ``.
436
+ (``'0' ``) character enables sign-aware zero-padding for numeric types,
437
+ excluding :class: ` complex ` . This is equivalent to a *fill * character of
438
+ ``'0' `` with an *alignment * type of ``'=' ``.
438
439
439
440
.. versionchanged :: 3.10
440
441
Preceding the *width * field by ``'0' `` no longer affects the default
@@ -588,6 +589,15 @@ The available presentation types for :class:`float` and
588
589
| | as altered by the other format modifiers. |
589
590
+---------+----------------------------------------------------------+
590
591
592
+ The available presentation types for :class: `complex ` are the same as those for
593
+ :class: `float ` (``'%' `` is not allowed). Both the real and imaginary components
594
+ of a complex number are formatted as floating-point numbers, according to the
595
+ specified presentation type. They are separated by the mandatory sign of the
596
+ imaginary part, the latter being terminated by a ``j `` suffix. If the presentation
597
+ type is missing, the result will match the output of :func: `str ` (complex numbers with
598
+ a non-zero real part are also surrounded by parentheses), possibly altered by
599
+ other format modifiers.
600
+
591
601
592
602
.. _formatexamples :
593
603
0 commit comments