Converters
Collection of tools for converting data.
The module contains the following functions:
to_human_size(n_bytes)
- Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc.
to_human_size(n_bytes)
¶
Converts the number of bytes into a human-readable format.
Examples:
>>> from xloft import to_human_size
>>> to_human_size(200)
200 bytes
>>> to_human_size(1048576)
1 MB
>>> to_human_size(1048575)
1023.999 KB
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_bytes
|
int
|
The number of bytes. |
required |
Returns:
Type | Description |
---|---|
str
|
Returns a humanized string: 200 bytes | 1 KB | 1.5 MB etc. |