Python Forum

Full Version: converting data sizes like: 4k, 32k, 4m, 16m, 1g, etc
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i'm getting a string with a data size expressed in it like "4k", "32k", "4m", "16m", "1g". is there a Python library function that will do the conversion and give me the size as an int? support for size expressions like "3.5k" would be a plus.

edit:

i do want higher scale suffixes, too, as well as no suffix simple conversion.

edit2:

suffixes should be powers of 1024.
with no answer and being unable to find one, i implemented my own which you can see here.