https://github.com/siznax/khnum
The god of human readable numbers
https://github.com/siznax/khnum
formatter human human-readable-numbers numbers python readability
Last synced: 10 months ago
JSON representation
The god of human readable numbers
- Host: GitHub
- URL: https://github.com/siznax/khnum
- Owner: siznax
- License: mit
- Created: 2019-08-23T18:28:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-18T16:45:29.000Z (over 6 years ago)
- Last Synced: 2025-05-07T02:28:47.758Z (10 months ago)
- Topics: formatter, human, human-readable-numbers, numbers, python, readability
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
khnum 𓎹𓃝
==========
the god of human readable numbers
Install
-------
```
pip install khnum
𓎹𓃝
```
Usage
-----
```
import khnum
```
Examples
--------
```
>>> khnum.cnum(1234567890)
'1,234,567,890'
```
```
>>> khnum.hnum(1234567890)
'1.2B'
```
```
>>> khnum.hnum(1234567890, 'bytes')
'1.2GB'
```
```
>>> khnum.hnum(1234567890, 'si')
'1.1GiB'
```
```
>>> num = khnum.num(1234567890, 'b')
>>> print(num)
{
"_num": 1234567890,
"cnum": "1,234,567,890",
"hnum": "1.2GB",
"line": "1.2GB (1,234,567,890)",
"type": "",
"units": "b"
}
```
Help
----
```
$ pydoc khnum
```
```
>>> help(khnum)
```
Test
----
```
$ pytest
```
Contributors
------------
* [Fred Cirera](https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size)
@siznax