格式化数字及其单位,格式化数字单位,[Python]代码de
格式化数字及其单位,格式化数字单位,[Python]代码de
[Python]代码
def fmtsize(n): s = str(n) size = s[-3:] while len(s) > 3: s = s[:-3] size = '%s,%s' % (s[-3:], size) if n > 999: unit = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'] i = 1 while i + 1 < len(unit) and (n >> 10) >= 999: i += 1 n >>= 10 n /= (1 << 10) size = '%s (%.0f %s)' % (size, n, unit[i]) return size
相关内容
- python socket单工聊天工具,pythonsocket单工,socket单工聊天
- 用Python编写的列举所有对称日的小程序--菜鸟写的,请
- python监控网卡流量,python监控网卡,[Python]代码im
- Find the coefficients of the polynomial that fits the specified data
- tinyipdate最新ip库 python操作类,tinyipdatepython,发布最新版
- Linux下歌词编辑器,Linux歌词编辑器,#!/usr/bin/e
- 支持编辑的词典,编辑词典,DictForGeeks
- Python倒计时代码,python倒计时,#!/usr/bin/e
- 教师统计学生交作业次数,教师统计作业次数,[Python]代
- select 实现的 socket服务器,selectsocket,[Python]代码im
评论关闭