locale module accesses a database of culture specific data formats : Locale : Language Basics PYTHON examples


PYTHON examples » Language Basics » Locale »

 

locale module accesses a database of culture specific data formats





#locale module accesses a database of culture specific data formats. The 
#grouping 
#attribute of locale's format function provides a direct way of formatting numbers 
#with group separators:

import locale
locale.setlocale(locale.LC_ALL, 'English_United States.1252')

conv = locale.localeconv()          # get a mapping of conventions
x = 1234567.8

locale.format("%d", x, grouping=True)

locale.format("%s%.*f"(conv['currency_symbol'],conv['frac_digits'], x), grouping=True)

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Language Basics
» Locale