mirror of
https://github.com/avipatilpro/FileStreamBot.git
synced 2026-01-15 14:22:53 -03:00
11 lines
267 B
Python
11 lines
267 B
Python
def humanbytes(size):
|
|
if not size:
|
|
return ""
|
|
power = 2**10
|
|
n = 0
|
|
Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'}
|
|
while size > power:
|
|
size /= power
|
|
n += 1
|
|
return str(round(size, 2)) + " " + Dic_powerN[n] + 'B'
|