locale.setlocale()
locale.setlocale() is a Python function in the Locale Module category. Sets the locale for a category (LC_ALL, LC_TIME, LC_NUMERIC, etc.). The syntax is locale.setlocale(category, locale=None). Parameters: category, locale string. Returns: Locale string or None. A typical example: import locale
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
locale.setlocale(locale.LC_TIME, "fr_FR.UTF-8"). A close sibling is locale.getlocale(), which returns the current locale setting as (language, encoding). A close sibling is locale.getdefaultlocale(), which returns the default locale from environment variables. A close sibling is locale.strcoll(), which compares two strings according to the current LC_COLLATE locale. A close sibling is locale.strxfrm(), which transforms a string to one that can be used in locale-aware comparisons. More about this category: Internationalization — setlocale, getlocale, currency, strcoll. Related Locale Module entries: locale.getlocale(), locale.getdefaultlocale(), locale.strcoll(), locale.strxfrm(), locale.format_string(), locale.currency(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.