'''
Created on 2017年9月8日
@author: Len
'''
import random
User_name,User_Pwd="Len","Len123"
check=''
def checking():
global check
for i in range(4):
cnumber=random.randint(0,4)
if cnumber == i:
x = chr(random.randint(65,90))
else:
x = random.randint(0,9)
check += str(x)
return check
def login():
username = input("请输入用户名:")
userpwd = input("请输入密码:")
while True:
if username == User_name and userpwd == User_Pwd :
print("用户名密码正确!")
checking()
print("验证码为:",check)
user_check=input("请输入验证码:")
if user_check==check:
print ("登陆成功!")
return
else:
print("输入错误!")
else:
print("输入错误,请重新输入!")
login()
Python中运用random函数模拟用户登录验证码
最新推荐文章于 2021-04-01 00:32:09 发布