python format string thousand separator with spaces

后端 未结 5 1512
悲哀的现实
悲哀的现实 2020-12-02 17:51

For printing number with thousand separator, one can use the python format string :

\'{:,}\'.format(1234567890)

But how can I specify that

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 18:33

    You'll have to use the 'n' locale-aware number format instead, and set your locale to one that uses a space as a thousands separator. Yes, this is painful.

    'n' - Number. This is the same as 'd', except that it uses the current locale setting to insert the appropriate number separator characters.

提交回复
热议问题