生成5+2, 6+1的随机数
Posted yspworld
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了生成5+2, 6+1的随机数相关的知识,希望对你有一定的参考价值。
import random def getBaseBigHapppyNumbers(): frontNumbers = set(); backNumbers = set(); while(len(frontNumbers)<5): cur = random.randint(1, 35) frontNumbers.add(cur) while(len(backNumbers)<2): cur = random.randint(1, 12) backNumbers.add(cur) sorted(frontNumbers) sorted(backNumbers) print("随机的组合为:") print(frontNumbers) print(backNumbers) def getDoubleColorBall(): frontNumbers = set(); backNumbers = set(); while(len(frontNumbers)<6): cur = random.randint(1, 33) frontNumbers.add(cur) while(len(backNumbers)<1): cur = random.randint(1, 16) backNumbers.add(cur) sorted(frontNumbers) sorted(backNumbers) print("随机的组合为:") print(frontNumbers) print(backNumbers) if __name__ == ‘__main__‘: getBaseBigHapppyNumbers() getDoubleColorBall()
以上是关于生成5+2, 6+1的随机数的主要内容,如果未能解决你的问题,请参考以下文章
python 如何生成 2 1 4 3 6 5 8 7。。。的指定长度的序列?