Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python get human readable file size

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}"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #human #readable #file #size
ADD COMMENT
Topic
Name
9+3 =