import random
redList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33]
blueList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
def getNums():
global redList
global blueList
myred = redList
tempList = []
for j in range(6):
# 红球
tempIndex = random.randint(0, len(myred) - 1)
a = myred.pop(tempIndex)
tempList.append(a)
tempList.sort()
# 蓝球
tempList.append(blueList[random.randint(0, len(blueList) - 1)])
print(tempList)
with open('numbers.txt', 'a+') as f:
f.write(tempList.str() + '\n')
if name == 'main':
# for i in range(10):
getNums()
复制上面的代码,随便找个在线编译python工具运行就行
网友评论