赞
踩
1.用户输入的验证码不区分大小写
2.如需验证大小写,则去掉if判断语句里面的lower()即可
- # 四个随机数验证码
- code = ''
- s = 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm0123456789'
- for i in range(4):
- ran = random.randint(0, len(s)-1)
- code += s[ran]
- print(code)
- user_name = input('请输入验证码:')
- if user_name.lower() == code.lower():
- print('验证码正确!!!!')
- else:
- print('验证码错误!!!')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。