Skip to main content

number_format

Format a numeric value using localization settings.

If use_l10n is provided and is not None, it forces the value to be localized (or not), otherwise it's always localized.

def number_format(
value: number|string,
decimal_pos: int = None,
use_l10n: boolean = None,
force_grouping: boolean = False
) - > string

Format a numeric value using localization settings. If use_l10n is provided and is not None, it forces the value to be localized (or not), otherwise it's always localized.

Parameters

NameTypeDescription
value`numberstring`
decimal_posint = NoneThe number of decimal places to display in the formatted output.
use_l10nboolean = NoneA flag to explicitly enable or disable localization; defaults to True if not provided.
force_groupingboolean = FalseWhether to force the use of digit grouping separators regardless of the current locale's default settings.

Returns

TypeDescription
stringThe formatted numeric string with appropriate separators and decimal precision based on the specified locale settings.