Skip to content

convert float string (decimal point or decimal comma) to float

License

Notifications You must be signed in to change notification settings

Yellorn/str2float

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

str2float

There are 3 ways to group the number ten thousand with digit group separators:

  1. Space: the internationally recommended thousands separator.
  2. Point: the thousands separator used in many non-English speaking countries.
  3. Comma: the thousands separator used in most English-speaking countries.

thousands separators


In which, there are 2 types of decimal separators:

  1. Decimal point
  2. Decimal comma

decimal separators


This package will help convert float string (decimal point or decimal comma) to float!

Installation:

https://pypi.org/project/str2float/

pip install str2float

Usage:

from str2float import str2float
float = str2float(str_float)

Example:

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 😘

About

convert float string (decimal point or decimal comma) to float

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published