locale
The locale module opens access to the POSIX locale database and functionality. The POSIX locale mechanism allows programmers to deal with certain cultural issues in an application, without requiring the programmer to know all the specifics of each country where the software is executed. [1]
Documentation
- Documentation [EN]
Examples
- Use German names for days and months
from datetime import datetime
from locale import setlocale, LC_TIME
setlocale(LC_TIME, 'de_CH.UTF-8')
now = datetime.now()
print(now.strftime('Day: %A\nMonth: %B'))
Output:
Day: Freitag
Month: Mai
References
- ↑ Python contributors. "locale." Python Software Foundation. https://docs.python.org/3/library/locale.html (accessed 05.05.2023)