mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 04:30:24 +01:00
py/objstr: Add support for the :_b/o/x specifier in str.format.
This groups non-decimal values by fours, such as bbb_bbbb_bbbb. It also
supports `{:_d}` to use underscore for decimal numbers (grouped in threes).
Use of incorrect ":,b" is not diagnosed.
Thanks to @dpgeorge for the suggestion to reduce code size.
Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
committed by
Damien George
parent
f47e214cdc
commit
9032491efd
@@ -22,7 +22,17 @@ test("{:4o}", 123)
|
||||
test("{:4x}", 123)
|
||||
test("{:4X}", 123)
|
||||
|
||||
test("{:4,d}", 1)
|
||||
test("{:4_d}", 1)
|
||||
test("{:4_o}", 1)
|
||||
test("{:4_b}", 1)
|
||||
test("{:4_x}", 1)
|
||||
|
||||
test("{:4,d}", 12345678)
|
||||
test("{:4_d}", 12345678)
|
||||
test("{:4_o}", 12345678)
|
||||
test("{:4_b}", 12345678)
|
||||
test("{:4_x}", 12345678)
|
||||
|
||||
test("{:#4b}", 10)
|
||||
test("{:#4o}", 123)
|
||||
|
||||
Reference in New Issue
Block a user