https://github.com/null-none/humansizes
Parse human-readable filesizes into bytes
https://github.com/null-none/humansizes
bytes filesize filesize-in-bytes humansize python
Last synced: 17 days ago
JSON representation
Parse human-readable filesizes into bytes
- Host: GitHub
- URL: https://github.com/null-none/humansizes
- Owner: null-none
- License: mit
- Created: 2024-10-19T12:46:08.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-19T12:53:56.000Z (6 months ago)
- Last Synced: 2025-02-11T12:35:10.172Z (2 months ago)
- Topics: bytes, filesize, filesize-in-bytes, humansize, python
- Language: Python
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# humansizes
## Overview
Parse human-readable filesizes into bytes### Install
```bash
pip install humansizes
```### Example
```python
from humansizes.convert import Humansizes
humansizes = Humansizes()
example_strings = ["1024b", "10.43 KB", "11 GB", "343.1 MB", "10.43KB", "11GB", "343.1MB", "10.43 kb", "11 gb", "343.1 mb", "10.43kb", "11gb", "343.1mb"]
for example_string in example_strings:
print(example_string, humansizes.parse_size(example_string))
``````bash
('1024b', 1024)
('10.43 KB', 10680)
('11 GB', 11811160064)
('343.1 MB', 359766425)
('10.43KB', 10680)
('11GB', 11811160064)
('343.1MB', 359766425)
('10.43 kb', 10680)
('11 gb', 11811160064)
('343.1 mb', 359766425)
('10.43kb', 10680)
('11gb', 11811160064)
('343.1mb', 359766425)
```