import random
random.seed(10)
def verifycode():
code_list = ''
# 每一位验证码都有三种可能(大写字母,小写字母,数字)
for i in range(6): # 控制验证码生成的位数
#********** Begin **********
s=random.randint(1,3)
# 大写字母
if s==1:
c=chr(random.randint(65,90))
# 小写字母
elif s==2:
c=chr(random.randint(97,122))
# 数字
else:
c=random.randint(0,9)
code_list=code_list+str(c)
#********** End **********
return code_list
if __name__ == '__main__':
verifycode = verifycode()
print(verifycode)
educoder-随机生成验证码
最新推荐文章于 2024-05-07 15:31:51 发布