用简单的Python语句写了个模拟双色球摇奖,希望能中。。
用简单的Python语句写了个模拟双色球摇奖,希望能中。。
import random; #利用Python中的random.sample()函数实现
resultList = random.sample(range(1, 34), 6); #sample(x,y)函数的作用是从序列x中,随机选择y个不重复的元素
resultList.sort() #从低到高排序
print(“红球的号码为:”+ str(resultList)) # 打印结果
resultList1=random.sample(range(1,17),1)
print(“蓝球的号码为:”+ str(resultList1 )) # 打印结果
希望大家都可以中哈~