import random
import sys
# 获取参数信息
if len(sys.argv) == 2:
r_num = int(sys.argv[1])
b_num = int(sys.argv[2])
else:
r_num = 5
b_num = 2
# 确定参数范围是否合理
if 5 <= r_num < 17 and b_num > 0 and b_num < 17:
# 产生随机数
x = random.sample(range(1, 35), r_num)
# 排序默认升序从小大大
x.sort()
y = random.sample(range(1, 12), b_num)
y.sort()
for red in x:
print("\033[31m %s" % red, end=' ')
print(':红区<<-->>蓝区:', end=' ')
for blue in y:
print("\033[34m %s" % blue, end=' ')
print("\033[0m 选号完毕!愿君高中!", end=' \n')
else:
print('输入有误,第一个数应大于等于5小于17,第二个数应大于0小于17')
日常pytho3练习脚本之–彩票(大乐透)自助选号机
- 郭良俊只狗
- 0