def human_size(size, a_kilobyte_is_1024_bytes=False, precision=1, target=None):
    if size < 0:
        raise ValueError('number must be non-negative')

    multiple = 1024 if a_kilobyte_is_1024_bytes else 1000
    for suffix in SUFFIXES[multiple]:

        if target:
            if suffix == target:
                break
            size /= float(multiple)
        else:
            if size >= multiple:
                size /= float(multiple)
            else:
                break

    return '{0:.{1}f}{2}'.format(size, precision, suffix)
Convert a file size to human-readable form.
dataset/ETHPy150Open tanghaibao/jcvi/utils/cbook.py/human_size