# -*- coding:utf-8 -*-
import random
class Money(object):
def __init__(self, A, B):
""" 初始化变量 """
self.Person_Math = int(A)
self.Money_Math = int(B)
def Money(self):
""" 实现随机红包金额"""
# 每个人不拿走大于红包75%的金额
first_person = 0
while self.Person_Math > 0:
get_money = 0
while True:
if self.Person_Math > 0:
get_money = random.randint(1, self.Money_Math)
if get_money <= self.Money_Math * 0.75:
self.Money_Math -= get_money
first_person += 1
break
elif self.Person_Math == 0:
first_person += 1
get_money = self.Money_Math
self.Person_Math = 0
self.
python实现抢红包的小程序
最新推荐文章于 2025-02-04 23:36:17 发布