[lang-ref] ( format_with_thousands_separator ) ( python )
@pytest.mark.parametrize(
'v, expected',
[
(12345678, '12,345,678'),
(-12345678, '-12,345,678'),
(-12345678.76543, '-12,345,678.76543'),
],
)
def test_format_with_thousands_separator_alternative(v, expected):
# format(v, ',')
# format
a = format(v, ',')
assert a == expected
# f-string
a = f'{v:,}'
assert a == expected
# printf-like : not support ','
# a = '%,d' % v