Metadata-Version: 2.5
Name: dmf-bytes
Version: 0.1.0
Summary: 将字节数转换成易读的文件大小
Author: dmf
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# dmf-bytes

一个零第三方依赖的 Python 小工具，将字节数转换为易读的文件大小。

## 安装

```bash
pip install dmf-bytes
```

## 使用

```python
from dmf_bytes import format_size

print(format_size(0))                 # 0 B
print(format_size(500))               # 500 B
print(format_size(1536))              # 1.5 KiB
print(format_size(1048576))           # 1.0 MiB
print(format_size(1536, precision=2)) # 1.50 KiB
```

## 参数

- `size`：非负整数字节数，负数会抛出 `ValueError`。
- `precision`：KiB 及以上单位的小数位数，默认是 `1`。

## 单位

每级按 1024 换算，支持 B、KiB、MiB、GiB、TiB。
最大显示单位为 TiB，更大的数值仍以 TiB 表示。