python 实例

时间:2021-06-20 18:07:43   收藏:0   阅读:0

# 四位验证码

"""四位数验证码"""
code=""
for i in range(4):
    print(i)
    index = random.randrange(4)  #0-3 中随机取一个数
    if index != i and index + 1 != i:
        code +=chr(random.randint(97,122))  #小写字母
    elif index + 1 == i:
        code +=chr(random.randint(65,90))   #大写字母
    else:
        code +=str(random.randint(1,9))
print(code)

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!