Skip to content

Instantly share code, notes, and snippets.

@cbattlegear
Last active August 31, 2017 16:07
Show Gist options
  • Save cbattlegear/0f5ea203d02e2aff3c6ca54a4447cbdf to your computer and use it in GitHub Desktop.
Save cbattlegear/0f5ea203d02e2aff3c6ca54a4447cbdf to your computer and use it in GitHub Desktop.
Quick Bandwidth Format function
def format_bandwidth(i):
loop = 0
current_num = i
last_num = 0
label = ["Bps", "KBps", "MBps", "GBps"]
while(True):
last_num = current_num
current_num = current_num/1024.0
if(current_num < 1):
return '{0:0.2f} {1}'.format(last_num, label[loop])
loop = loop + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment