本站改版新增arduino频道

Micropython
Arduino

micropython 字节单位转换


#字节单位转换
def ToSize(size):
   ds = ['b','KB','MB','GB','TB']
   for d in ds:
       if size < 1024: return str(size)+d
       size = size / 1024
   return '0b'

print(ToSize(10000))



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号

执行时间: 0.0095460414886475 seconds