There are 3 ways to group the number ten thousand with digit group separators:
- Space: the internationally recommended thousands separator.
- Point: the thousands separator used in many non-English speaking countries.
- Comma: the thousands separator used in most English-speaking countries.
In which, there are 2 types of decimal separators:
- Decimal point
- Decimal comma
This package will help convert float string (decimal point or decimal comma) to float!
https://pypi.org/project/str2float/
pip install str2float
from str2float import str2float
float = str2float(str_float)
from str2float import str2float
if __name__ == "__main__":
assert str2float("1") == 1.0
assert str2float("1.2345") == 1.2345
assert str2float("1.23") == 1.23
assert str2float("1.2") == 1.2
assert str2float("1,2345") == 1.2345
assert str2float("1,23") == 1.23
assert str2float("1,2") == 1.2
assert str2float("1234,5") == 1234.5
assert str2float("1.234,5") == 1234.5
assert str2float("1,234.5") == 1234.5
assert str2float("1,234,567.85") == 1234567.85
assert str2float("1.234.567,85") == 1234567.85
From hoangyell with love 😘