Python locale Module
Example
Print the decimal separator from the current locale (no system changes):
import locale
conv = locale.localeconv()
print(conv["decimal_point"])
Try it Yourself »
Definition and Usage
The locale module provides access to POSIX locale databases and functionality.
Use it to format numbers, currencies, and dates according to cultural conventions.
Beware that setting locales is platform-specific.
Members
Member | Description |
---|---|
setlocale() | Set the current locale for a category (like LC_ALL). |
localeconv() | Return numeric and monetary formatting information as a dict. |
strxfrm() | Transform a string for locale-aware comparisons. |
getpreferredencoding() | Return the encoding used for system interfaces. |