python微信拼手气红包逻辑

import random


def red_packet(money, num):
    money = money * 100
    ret = random.sample(range(1, money), num - 1)
    ret.append(0)
    ret.append(money)
    ret.sort()
    return [(ret[i+1]- ret[i]) / 100 for i in range(len(ret) - 1)]
posted @ 2020-01-06 15:30  JaryTom  阅读(794)  评论(0编辑  收藏  举报