- def ByteFormat(size,unit='Bytes'):
- units = ['Bytes','KB','MB','GB','TB','PB']
- return ('%.2f'+" "+unit) % (size/math.pow(1024,units.index(unit)))
- #该片段来自于http://www.codesnippet.cn/detail/0204201512079.html
来源: http://www.codesnippet.cn/detail/0204201512079.html