How do I format 1000000
to 1.000.000
in Python? where the '.' is the decimal-mark thousands separator.
相关问题
- 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
Using
itertools
can give you some more flexibility:If you want to add a thousands separator, you can write:
But it only works in Python 2.7 and higher.
See format string syntax.
In older versions, you can use locale.format():
the added benefit of using
locale.format()
is that it will use your locale's thousands separator, e.g.