Use base 10 to calculate pretty_bytes. Fixes #28

This commit is contained in:
Manu 2018-11-21 21:34:28 +08:00
parent 6b25a8d78f
commit 3f7249fb44
1 changed files with 2 additions and 2 deletions

View File

@ -94,13 +94,13 @@ def pretty_bytes(size):
python-format-size-application-converting-b-to-kb-mb-gb-tb/37423778"""
if type(size) != int:
return ''
power = 2**10
power = 1000 # GiB is base 2**10, GB is base 10**3.
n = 0
Dic_powerN = {0: '', 1: 'K', 2: 'M', 3: 'G', 4: 'T'}
while size > power:
size /= power
n += 1
return str(round(size))+Dic_powerN[n]+'B'
return f'{round(size, 1)} {Dic_powerN[n]}B'
def get_asset(path):