import random

# 生成随机验证码
# 数字验证码

check_code = ''

for i in range(4):
current = random.randint(1, 9)
check_code += str(current)

print(check_code)

# 随机字母+数字验证码

check_code = ''

for i in range(4):
current = random.randrange(0, 4)
if current == i:
tmp = chr(random.randint(65, 90))
else:
tmp = random.randint(0, 9)
check_code += str(tmp)
print(check_code)
posted on 2019-06-28 17:29  Yihan_07  阅读(3456)  评论(0编辑  收藏  举报