import random def red_packet(money,num): money = money * 100 ret = random.sample(range(1,money),num-1) ret.sort() ret.insert(0,0) ret.append(money) for i in range(len(ret)-1): yield (ret[i+1] - ret[i])/100 ret_g = red_packet(200,10) for money in ret_g: print(money) #19.29/13.59/22.88/8.71/3.27/26.25/15.86/29.69/42.64/17.82
使用python制作发红包小工具,