size¶
-
hhpy.main.
size
(byte: int, unit: str = 'MB', dec: int = 2) → str[source]¶ Formats bytes as human readable string
Parameters: - byte – The byte amount to be formated
- unit – The unit to display the output in, supports ‘KB’, ‘MB’, ‘GB’ and ‘TB’
- dec – The number of decimals to use
Returns: Formated bytes as string
Examples
>>> size(1024, unit='KB') '1.0 KB'
>>> size(1024*1024*10, unit='MB') '10.0 MB'
>>> size(10**10, unit='GB') '9.31 GB'