How can I format a decimal number so that 32757121.33
will display as 32.757.121,33
?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Use
locale.format()
:You can restrict the locale changes to the display of numeric values (when using
locale.format()
,locale.str()
etc.) and leave other locale settings unaffected:If you can't or don't want to use
locale
for some reason, you can also do it with a regular expression:sep()
takes the string representation of a standard Python float and returns it with custom thousands and decimal separators.Explanation:
I have found another solution: