티스토리 뷰

728x90
# Locale unaware
'{:,}'.format(value)  # For Python ≥2.7
f'{value:,}'  # For Python ≥3.6
Locale aware


# import locale
locale.setlocale(locale.LC_ALL, '')  # Use '' for auto, or force e.g. to 'en_US.UTF-8'

'{:n}'.format(value)  # For Python ≥2.7
f'{value:n}'  # For Python ≥3.6

https://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators

 

How to print number with commas as thousands separators?

I am trying to print an integer in Python 2.6.1 with commas as thousands separators. For example, I want to show the number 1234567 as 1,234,567. How would I go about doing this? I have seen many

stackoverflow.com

 

728x90

'공부' 카테고리의 다른 글

[Java] Download filename encoding `UTF-8`  (0) 2020.04.03
[iBatis] escape `#` & `$`  (0) 2020.04.03
[Github] README.md show image  (0) 2020.04.03
[Python] requests UserAgent  (0) 2020.04.03
[Python] trim ==> strip 공백제거  (0) 2020.04.03
댓글