标签:第一个 sep cut ups groups += ret [] app
def cut_num(n, sep=','): # 第一个参数是要传递的数字,第二个是分隔符 s = str(abs(n))[::-1] groups = [] i = 0 while i < len(s): groups.append(s[i:i+3]) i+=3 retval = sep.join(groups)[::-1] if n < 0: return '-%s' % retval else: return retval标签:第一个 sep cut ups groups += ret [] app
原文地址:http://blog.51cto.com/haoyonghui/2133156