Skip to main content

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

Project description

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 😘

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

str2float-0.0.9.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

str2float-0.0.9-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page