@@ -319,14 +319,19 @@ non-empty format specification typically modifies the result.
319319The general form of a *standard format specifier * is:
320320
321321.. productionlist :: format-spec 
322-    format_spec: [[`fill `]`align`][`sign `]["z"]["#"]["0"][`width `][`grouping_option `]["." `precision `][`type `]
322+    format_spec: [`options `][`width_and_precision `][`type `]
323+    options: [[`fill `]`align`][`sign `]["z"]["#"]["0"]
323324   fill: <any character>
324325   align: "<" | ">" | "=" | "^"
325326   sign: "+" | "-" | " "
327+    width_and_precision: [`width_with_grouping `][`precision_with_grouping `]
328+    width_with_grouping: [`width `][`grouping_option `]
329+    precision_with_grouping: "." [`precision `]`grouping_option`
326330   width: `~python-grammar:digit`+
327331   grouping_option: "_" | ","
328332   precision: `~python-grammar:digit`+
329-    type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
333+    type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g"
334+        : | "G" | "n" | "o" | "s" | "x" | "X" | "%"
330335
331336If a valid *align * value is specified, it can be preceded by a *fill *
332337character that can be any character and defaults to a space if omitted.
@@ -458,6 +463,13 @@ indicates the maximum field size - in other words, how many characters will be
458463used from the field content.  The *precision * is not allowed for integer
459464presentation types.
460465
466+ The ``'_' `` or ``',' `` option after *precision * means the use of an underscore
467+ or a comma for a thousands separator of the fractional part for floating-point
468+ presentation types.
469+ 
470+ .. versionchanged :: 3.14 
471+    Support thousands separators for the fractional part.
472+ 
461473Finally, the *type * determines how the data should be presented.
462474
463475The available string presentation types are:
@@ -704,10 +716,18 @@ Replacing ``%x`` and ``%o`` and converting the value to different bases::
704716   >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42) 
705717   'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010' 
706718
707- Using the comma as a thousands separator::
719+ Using the comma or the underscore  as a thousands separator::
708720
709721   >>> '{:,}'.format(1234567890) 
710722   '1,234,567,890' 
723+    >>> '{:_}'.format(1234567890) 
724+    '1_234_567_890' 
725+    >>> '{:_}'.format(123456789.123456789) 
726+    '123_456_789.12345679' 
727+    >>> '{:._}'.format(123456789.123456789) 
728+    '123456789.123_456_79' 
729+    >>> '{:_._}'.format(123456789.123456789) 
730+    '123_456_789.123_456_79' 
711731
712732Expressing a percentage::
713733
0 commit comments