On this page
  1. locale.format_string
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

locale.format_string

Prev: locale.Error | Up: locale | Next: locale.getdefaultlocale
Rel: locale.atof, locale.atoi, locale.currency, locale.Error
Ref: docs.python.org — locale.format_string
Tags: #public #python3 #stdlib #locale


Import

import locale
from locale import format_string

Signature & Overview

locale.format_string(f, val, grouping=False, monetary=False)

Formats a string in the same way that the % formatting would use, but takes the current locale into account.

Usage

import locale

assert locale.format_string("%.2f", 1234.5, grouping=True).endswith("50")

Gotchas

REPL Inspect

from locale import format_string
help(format_string)

Linked from

Related notes