Convert bytes to human-readable sizes (KB, MB, KiB, MiB, etc.)
Project description
humanbytes
humanbytes is a simple Python package to convert bytes into human-readable sizes using either decimal (KB, MB, ...) or binary (KiB, MiB, ...) units.
Features
- Convert bytes to a human-readable string
- Supports both decimal (powers of 1000) and binary (powers of 1024) units
- Minimal, dependency-free, and easy to use
Installation
pip install humanbytes
Usage
from humanbytes import human_size
print(human_size(1536)) # 1.54 KB
print(human_size(1536, binary=True)) # 1.50 KiB
print(human_size(10**9)) # 1.00 GB
print(human_size(2**30, binary=True)) # 1.00 GiB
Parameters
num: The number to convert (e.g., bytes)binary: If True, use binary units (KiB, MiB, ...). If False (default), use decimal units (KB, MB, ...)
License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file humanbytes-0.1.0-py3-none-any.whl.
File metadata
- Download URL: humanbytes-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7c209c72ef49ff324bd4e63ebc6d47ff74ec8df23850917ba8050c84644cb1e
|
|
| MD5 |
451329f236c95deafb4b93fab696e1cf
|
|
| BLAKE2b-256 |
68471dfd0c8eba577d358fd8421c681e435fb0ff7aa1bf4290dd592554d8d9cc
|