[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(v, expected):
# f'{v:,}'
a = f'{v:,}'
assert a == expected
# Note: printf-like-format : not supports ','.
# a = '%,d' % v
@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, ',')
a = format(v, ',')
assert a == expected