https://github.com/jongha/python-formatbytes
Python-formatbytes is bytes to a readable string Converter. It supports the conversion of the unit such as B, KB, MB, GB, TB, PB, EB, ZB, YB. It also supports Kilobyte and Kibibyte.
https://github.com/jongha/python-formatbytes
bytes conversion python python-formatbytes readable-string-converter
Last synced: 11 months ago
JSON representation
Python-formatbytes is bytes to a readable string Converter. It supports the conversion of the unit such as B, KB, MB, GB, TB, PB, EB, ZB, YB. It also supports Kilobyte and Kibibyte.
- Host: GitHub
- URL: https://github.com/jongha/python-formatbytes
- Owner: jongha
- License: mit
- Created: 2013-12-23T15:09:09.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-24T14:42:36.000Z (over 12 years ago)
- Last Synced: 2025-08-15T20:18:42.036Z (11 months ago)
- Topics: bytes, conversion, python, python-formatbytes, readable-string-converter
- Language: Python
- Homepage: https://pypi.python.org/pypi/formatbytes
- Size: 113 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Format Bytes
[](https://travis-ci.org/jongha/python-formatbytes)
Python-formatbytes is bytes to a readable string Converter. It supports the conversion of the unit such as B, KB, MB, GB, TB, PB, EB, ZB, YB. It also supports Kilobyte and Kibibyte.
## Usage
### Setup
$ python ./setup.py install
### Test
$ python ./run.py
### Using as a library
Copy formatbytes.py anywhere you want and create new file include below codes.
from formatbytes.formatbytes import FormatBytes
f = FormatBytes()
bytes, step, unit = f.convert(bytes=1024)
result = f.format(bytes=bytes, unit=unit, precision=2, comma=True)
print(result)
### From the command line
usage: formatbytes.py [-h] [-u [B|KB|MB|GB|TB|PB|EB|ZB|YB]] [-p [integer]]
[-c] [-m [1024|1000]]
bytes
Format Bytes for Python
positional arguments:
bytes Bytes for Formatting.
optional arguments:
-h, --help show this help message and exit
-u [B|KB|MB|GB|TB|PB|EB|ZB|YB]
Target unit to convert.
-p [integer] Precision of floating point.
-c Print with commas.
-m [1024|1000] Set the byte multiple.
## License
python-formatbytes is available under the terms of the MIT License.