Is it possible to get the output of
1M
1.01M
by changing the format
's value in the following code?
import humanize
format = "%.2f"
raw1 = 1_048_576;
raw2 = 1_058_576
print(humanize.naturalsize(raw1, format=format, gnu=True));
print(humanize.naturalsize(raw2, format=format, gnu=True));
One possible solution could be post-process the string afterwards:
Prints: