mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
py/mpprint: Correctly format leading zeros with separators.
Correctly format integers when there are leading zeros with a grouping
character, such as "{:04,d}".format(0x100) -> "0,256".
The new padding patterns for commas-and-zeroes and underscores-and-zeroes
are smooshed together into the existing pad_zeroes to save space.
Only the two combinations of (decimal + commas) and (other bases +
underscores) are properly supported.
Also add a test for it.
Fixes issue #18082.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
committed by
Damien George
parent
01a11ea45e
commit
5552fbe172
9
tests/basics/string_format_sep.py
Normal file
9
tests/basics/string_format_sep.py
Normal file
@@ -0,0 +1,9 @@
|
||||
try:
|
||||
"%d" % 1
|
||||
except TypeError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
for v in (0, 0x10, 0x1000, -0x10, -0x1000):
|
||||
for sz in range(1, 12): print(("{:0%d,d}" % sz).format(v))
|
||||
for sz in range(1, 12): print(("{:0%d_x}" % sz).format(v))
|
||||
Reference in New Issue
Block a user