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
Reference
Per Format Specification Mini-Language,
The
','
option signals the use of a comma for a thousands separator. For a locale aware separator, use the'n'
integer presentation type instead.
Related Posts:
- Purpose of “%matplotlib inline”
- How do I update Anaconda?
- TypeError: ‘str’ object is not callable (Python)
- Dijkstra’s algorithm in python
- How to create a GUID/UUID in Python
- Replace ‘ with \’ in a string
- How can I install pip on Windows?
- Best way to convert string to bytes in Python 3?
- Does Python have a string ‘contains’ substring method?
- Difference between import numpy and import numpy as np
- No module named ‘sklearn.cross_validation’
- Maximum and Minimum values for ints
- Arrays used as indices must be of integer (or boolean) type
- Are static class variables possible in Python?
- Why am I getting “LinAlgError: Singular matrix” from grangercausalitytests?
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- How do I copy a file in Python?
- EOFError: Ran out of input
- Get Color Palettes from ColorHunt.co in Python
- What does the Pydoc module do?
- size of NumPy array
- Best way to strip punctuation from a string
- How can I explicitly free memory in Python?
- filename.whl is not supported wheel on this platform
- What is the meaning of [:] in python [duplicate]
- Finding and replacing elements in a list
- socket.error: [Errno 48] Address already in use
- No module named MySQLdb
- How to determine a Python variable’s type?
- Could not find a version that satisfies the requirement
- Removing Conda environment
- Cannot convert list to array: ValueError: only one element tensors can be converted to Python scalars
- How do I plot only a table in Matplotlib?
- Change column type in pandas
- Split by comma and strip whitespace in Python
- How to remove punctuation marks from a string in Python 3.x using .translate()?
- Calculating Covariance with Python and Numpy
- What is the easiest way to remove all packages installed by pip?
- In practice, what are the main uses for the new “yield from” syntax in Python 3.3?
- Subplot for seaborn boxplot
- Dump a NumPy array into a csv file
- ‘Jupyter’ is not recognized as an internal or external command
- How to print spaces in Python?
- installing urllib in Python3.6
- What is sys.maxint in Python 3?
- How do you get the magnitude of a vector in Numpy?
- Finding all possible permutations of a given string in python
- Exit while loop in Python
- How do I check if a list is empty?
- IndexError: list index out of range and python
- Don’t understand why UnboundLocalError occurs (closure) [duplicate]
- OSError – Errno 13 Permission denied
- ImportError: No module named ‘Queue’
- ImportError: No Module Named bs4 (BeautifulSoup)
- How to calculate rolling / moving average using python + NumPy / SciPy?
- sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 74 supplied
- TypeError: ‘int’ object does not support item assignment
- Convert datetime to Unix timestamp and convert it back in python
- Defining lists as global variables in Python
- How to stop Python closing immediately when executed in Microsoft Windows
- Error: “dictionary update sequence element #0 has length 1; 2 is required” on Django 1.4
- module has no attribute
- Python script to copy text to clipboard
- How can I check if character in a string is a letter? (Python)
- OSError: Initializing from file failed on csv in Pandas
- TypeError: ‘numpy.float64’ object does not support item assignment
- TypeError: unsupported format string passed to list.__format__
- Getting “socket.error: [Errno 61] Connection refused” python paramiko
- python setup.py uninstall
- ImportError: No module named cv2
- ./xx.py: line 1: import: command not found
- How do I run pip on python for windows?
- How to open every file in a folder
- Python iteration over non-sequence
- How do I convert a string to a double in Python?
- _csv.Error: field larger than field limit (131072)
- How do I rotate an image around its center using Pygame?
- How can I copy a Python string?
- Issue with virtualenv – cannot activate
- Can I set max_retries for requests.request?
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- How to obfuscate Python code effectively?
- Controlling mouse with Python
- TypeError: coercing to Unicode: need string or buffer, int found
- Are nested try/except blocks in Python a good programming practice?
- Getting a name error when trying to input a string [duplicate]
- Complex number troubles with numpy
- Running shell command and capturing the output
- Determine if 2 lists have the same elements, regardless of order? [duplicate]
- Python copy files to a new directory and rename if file name already exists
- Package libffi was not found in the pkg-config search path REDHAT6.5
- Line is too long. Django PEP8
- TypeError: zip argument #2 must support iteration
- CS231n: How to calculate gradient for Softmax loss function?
- How to create a new database using SQLAlchemy?
- Python 3 integer division [duplicate]
- numpy/scipy/ipython:Failed to interpret file as a pickle
- What is the Python equivalent of static variables inside a function?
- Python – difference between two strings
- Flask-framework: MVC pattern