nanos.fmt module

nanos.fmt.size(size_bytes: int | float, precision: int = 2) str

Converts the given size in bytes into a human-friendly string representation.

Parameters:
  • size_bytes (int or float) – The size in bytes to convert.

  • precision (int, optional) – The number of decimal places to round the result to. Defaults to 2.

Returns:

A human-friendly string representation of the given size,

e.g. 4.00 B, 1.00 KiB, 1.23 MiB, etc.

Return type:

str