22.完成彩票36選7的功能. 從36個數中隨機的產生7個數. 最終獲取到7個不重復的數據作為最終的開獎結果.
隨機數:
from random import randint
randint(0, 20) # 0 - 20 的隨機數
import random set = set() # 如果集合元素到達7個,循環停止 while 7-len(set):r = random.randint(1,36)# print(r) set.add(r) print(set,type(set))
?
22.完成彩票36選7的功能. 從36個數中隨機的產生7個數. 最終獲取到7個不重復的數據作為最終的開獎結果.
隨機數:
from random import randint
randint(0, 20) # 0 - 20 的隨機數
import random set = set() # 如果集合元素到達7個,循環停止 while 7-len(set):r = random.randint(1,36)# print(r) set.add(r) print(set,type(set))
?
轉載于:https://www.cnblogs.com/apollo1616/p/9462649.html
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态