Paste a formatted number or date or click an example below to see the format specification you need.
variable = 1970.5
formatted = f"{variable:,.2f}"
print(formatted) # Output: 1,970.50Don't have a formatted string? Click an example string to analyze it or click a format specification to copy it.
| Description | Example Output | Format Specification | Example Input |
|---|---|---|---|
| Description | Example Output | Format Specification |
|---|---|---|
For datetime formatting and parsing help, see https://pym.dev/strptime.
For a reference guide to Python's f-string format specifications, see my article on how to use Python's f-strings or checkout fstring.help/cheat.
If you need very thorough reference, check out the official Format Specification Mini-Language documentation.
If you think you've found a formatting edge case or bug on this page, please report it to help@pythonmorsels.com.