📌  相关文章
📜  python 获取人类可读的文件大小 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:10.227000             🧑  作者: Mango

代码示例1
def human_readable_size(size, decimal_places=3):
    for unit in ['B','KiB','MiB','GiB','TiB']:
        if size < 1024.0:
            break
        size /= 1024.0
    return f"{size:.{decimal_places}f}{unit}"