Python-大乐透
import random,string nums = set() num = input('请输入要产生多少注:').strip() while len(nums)!=int(num): before = ' '.join(sorted(random.sample([str(nember).zfill(2)for nember in range(1,33)],5))) back = ' '.join(sorted(random.sample([str(n).zfill(2)for n in range(1,13)],2))) numbers = ('前区:%s 后区:%s\n'%(before,back)) nums.add(numbers) with open('大乐透.txt','a+',encoding='utf-8') as fw: fw.writelines(nums)
本文来自博客园,作者:他还在坚持嘛,转载请注明原文链接:他还在坚持嘛 https://www.cnblogs.com/brf-test/p/12656623.html