标签:random pack append range sam port 原理 input i+1
import random
def red_packet(money,num):
money = money*100
ret = random.sample(range(0,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)
money = int(input(‘你要发红包的金额‘))
num = int(input(‘你要发红包的人数‘))
ret_g = red_packet(money,num)
for money in ret_g:
print(money)
标签:random pack append range sam port 原理 input i+1
原文地址:https://www.cnblogs.com/The-Meaning-of-Life111/p/11552455.html