会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
wwzhen
博客园
首页
新随笔
联系
订阅
管理
2021年2月23日
python 按百分比抽奖
摘要: 通过给定百分比实现抽奖 def weighted_random(items): # 抽奖概率 [('iphone', 10), ('ipad', 40), ('itouch', 50)] total = sum(w for _, w in items) n = random.uniform(0, t
阅读全文
posted @ 2021-02-23 17:06 wwzhen
阅读(383)
评论(0)
推荐(0)
公告