How To Convert Numbers To String With Decimal And Commas
I'd like to convert a number like 1323.67 to 1.323,67, how can I do that? I've tried this f'{1325.76:.,2f}' but it prints out 1,325.76 I excpected f'{1325.76:.,2f}' to be 1.325,75
Solution 1:
If you can use external modules, I would suggest you to use babel
>>>from babel.numbers import format_decimal>>>format_decimal(1323.67, locale='de_DE')
'1.323,67'
Post a Comment for "How To Convert Numbers To String With Decimal And Commas"