python random模块生成随机验证码

生成随机验证码:

import random

checkcode=""
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)
    checkcode+=str(tmp)
print(checkcode)
posted @ 2020-01-03 11:14  努力乄小白  阅读(393)  评论(0编辑  收藏  举报