str() with float an i18n - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: str() with float an i18n (/thread-14921.html) |
str() with float an i18n - Skaperen - Dec-24-2018 as we know, some places use '.' and some places use ',' to separate the whole part of a number from the fractional part of a number. my curiosity question is whether the str() function uses the local preference, or if it just uses '.' everywhere. RE: str() with float an i18n - Larz60+ - Dec-25-2018 here's the doc on that: https://docs.python.org/3.7/library/locale.html?highlight=locale%20dependent#locale.LC_NUMERIC Quote:locale.setlocale(category, locale=None)I haven't actually tried it, but looks like it will accommodate numbers using LC_NUMERIC 'locale.localeconv()' Returns the database of the local conventions as a dictionary. Leave testing to you. RE: str() with float an i18n - Skaperen - Dec-25-2018 as long as str() does it, with whatever setup that is needed, if any, has been done, then i can "cheat" and just use str(1.5)[1] to get the right character.
|