py数据单位转换 2015/03/29 13232 def ByteFormat(size,unit='Bytes'): units = ['Bytes','KB','MB','GB','TB','PB'] return ('%.2f'+" "+unit) % (size/math.pow(1024,units.index(unit)))